Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
NoelDeMartin committed May 24, 2024
1 parent 5d92be4 commit a09bf13
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/engines/SolidEngine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { arrayFrom, arrayUnique, isObject, urlParentDirectory, urlRoot } from '@noeldemartin/utils';
import { arrayFrom, arrayUnique, isObject, toString, urlParentDirectory, urlRoot } from '@noeldemartin/utils';
import { compactJsonLDGraph, quadsToJsonLD } from '@noeldemartin/solid-utils';
import {
DocumentAlreadyExists,
Expand Down Expand Up @@ -177,7 +177,7 @@ export class SolidEngine implements Engine {
const rdfsClasses = this.extractJsonLDGraphTypes(filters);

return filters.$in
? await this.getDocumentsFromUrls(filters.$in, rdfsClasses)
? await this.getDocumentsFromUrls(filters.$in.map(toString), rdfsClasses)
: await this.client.getDocuments(collection, rdfsClasses.includes(IRI('ldp:Container')));
}

Expand Down
7 changes: 4 additions & 3 deletions src/models/SolidModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1222,13 +1222,14 @@ export class SolidModel extends SolidModelBase {
return this.newInstance(attributes, true);
};

const resource = await RDFDocument.resourceFromJsonLDGraph(document as JsonLDGraph, resourceId || id);
const documentUrl = toString(id);
const resource = await RDFDocument.resourceFromJsonLDGraph(document as JsonLDGraph, resourceId || documentUrl);
const model = await createModel();

await model.loadDocumentModels(id, document);
await model.loadDocumentModels(documentUrl, document);

return tap(model, m => {
m._sourceDocumentUrl = urlClean(id, { fragment: false });
m._sourceDocumentUrl = urlClean(documentUrl, { fragment: false });
m._usesRdfAliases = this.static('rdfsClassesAliases').some(
types => !types.some(type => !resource.isType(type)),
);
Expand Down
4 changes: 3 additions & 1 deletion src/models/SolidTypeIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export default class SolidTypeIndex extends Model {

return asyncFirst(
containerRegistrations,
registration => (containerClass ?? SolidContainer).find(registration?.instanceContainer) as Promise<T>,
async registration => registration?.instanceContainer
? (containerClass ?? SolidContainer).find(registration.instanceContainer) as Promise<T>
: null,
);
}

Expand Down
2 changes: 2 additions & 0 deletions src/models/history/PropertyOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Model from './PropertyOperation.schema';

export default class PropertyOperation extends Model {

declare public property: string;

public apply(model: SolidModel): void {
const field = model.static().getRdfPropertyField(this.property);

Expand Down
7 changes: 6 additions & 1 deletion src/models/relations/SolidContainsRelation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ export default class SolidContainsRelation<
}

public setForeignAttributes(related: Related): void {
if (!related.url || this.parent.resourceUrls.includes(related.getDocumentUrl())) {
const relatedDocumentUrl = related.getDocumentUrl();

if (
!related.url ||
(relatedDocumentUrl && this.parent.resourceUrls.includes(relatedDocumentUrl))
) {
return;
}

Expand Down
7 changes: 6 additions & 1 deletion src/models/relations/SolidIsContainedByRelation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ export default class SolidIsContainedByRelation<
}

public setForeignAttributes(related: Related): void {
if (!this.parent.url || related.resourceUrls.includes(this.parent.getDocumentUrl())) {
const parentDocumentUrl = this.parent.getDocumentUrl();

if (
!this.parent.url ||
(parentDocumentUrl && related.resourceUrls.includes(parentDocumentUrl))
) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { arrayUnique, tap } from '@noeldemartin/utils';
import { MultiModelRelation } from 'soukai';
import { MultiModelRelation, requireBootedModel } from 'soukai';

Check failure on line 2 in src/models/relations/mixins/SolidMultiModelDocumentRelation.ts

View workflow job for this annotation

GitHub Actions / ci

'requireBootedModel' is defined but never used
import type { Attributes, Key } from 'soukai';
import type { ClosureArgs } from '@noeldemartin/utils';

Expand Down Expand Up @@ -106,8 +106,9 @@ export default class SolidMultiModelDocumentRelation<
await this.parent.save();
}

public detach(this: This<Parent, Related, RelatedClass>, keyOrModel: string | Related): void {
const localKey = typeof keyOrModel === 'string' ? keyOrModel : keyOrModel.getAttribute(this.localKeyName);
public detach(this: This<Parent, Related, RelatedClass>, keyOrModel: Key | Related): void {
const isRelated = (related: unknown): related is Related => related instanceof this.relatedClass;
const localKey = isRelated(keyOrModel) ? keyOrModel.getAttribute(this.localKeyName) : keyOrModel;
const detachedModel = this.related?.find(model => model.getAttribute(this.localKeyName) === localKey);

if (!detachedModel) {
Expand Down

0 comments on commit a09bf13

Please sign in to comment.