@coasys/ad4m 0.12.0-rc1-dev.3 → 0.12.0-rc1-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -22528,11 +22528,25 @@ FETCH links
22528
22528
  // entirely and let innerUpdate write the links directly.
22529
22529
  const metadata = this.constructor.getModelMetadata();
22530
22530
  const hasConstructor = Object.values(metadata.properties).some((p) => p.required || p.flag || p.initial !== undefined);
22531
+ // Track properties that have resolveLanguage (non-literal) so they can be
22532
+ // set via setProperty after createSubject (which doesn't resolve languages).
22533
+ const deferredResolveLanguageProps = [];
22531
22534
  if (hasConstructor) {
22532
22535
  // First filter out the properties that are not relations (arrays)
22533
22536
  const initialValues = {};
22534
22537
  for (const [key, value] of Object.entries(this)) {
22535
22538
  if (value !== undefined && value !== null && !(Array.isArray(value) && value.length > 0) && !value?.action) {
22539
+ // Check if this property requires language resolution (e.g. file storage).
22540
+ // If so, resolve the expression *before* passing to createSubject so
22541
+ // the constructor receives a valid URI instead of raw data.
22542
+ const propMeta = metadata.properties[key];
22543
+ if (propMeta?.resolveLanguage && propMeta.resolveLanguage !== 'literal' && typeof value === 'object') {
22544
+ // Defer these properties — they need createExpression which may
22545
+ // fail inside a batch context on some languages. We'll set them
22546
+ // via setProperty after createSubject.
22547
+ deferredResolveLanguageProps.push(key);
22548
+ continue;
22549
+ }
22536
22550
  initialValues[key] = value;
22537
22551
  }
22538
22552
  }
@@ -22545,6 +22559,15 @@ FETCH links
22545
22559
  // When createSubject was skipped (no constructor actions), we must enable
22546
22560
  // property writing so that scalar values are persisted as links.
22547
22561
  await this.innerUpdate(!hasConstructor, batchId);
22562
+ // Now handle any deferred resolveLanguage properties that were excluded
22563
+ // from initialValues. setProperty will call createExpression to upload
22564
+ // the data to the appropriate language and store the resulting URI.
22565
+ for (const key of deferredResolveLanguageProps) {
22566
+ const value = this[key];
22567
+ if (value !== undefined && value !== null) {
22568
+ await this.setProperty(key, value, batchId);
22569
+ }
22570
+ }
22548
22571
  // If we got a batchId passed in, we let the caller decide when to commit.
22549
22572
  // We can't call getData() since the instance won't exist in the perspective
22550
22573
  // until the batch is committed.
package/lib/index.js CHANGED
@@ -22524,11 +22524,25 @@ FETCH links
22524
22524
  // entirely and let innerUpdate write the links directly.
22525
22525
  const metadata = this.constructor.getModelMetadata();
22526
22526
  const hasConstructor = Object.values(metadata.properties).some((p) => p.required || p.flag || p.initial !== undefined);
22527
+ // Track properties that have resolveLanguage (non-literal) so they can be
22528
+ // set via setProperty after createSubject (which doesn't resolve languages).
22529
+ const deferredResolveLanguageProps = [];
22527
22530
  if (hasConstructor) {
22528
22531
  // First filter out the properties that are not relations (arrays)
22529
22532
  const initialValues = {};
22530
22533
  for (const [key, value] of Object.entries(this)) {
22531
22534
  if (value !== undefined && value !== null && !(Array.isArray(value) && value.length > 0) && !value?.action) {
22535
+ // Check if this property requires language resolution (e.g. file storage).
22536
+ // If so, resolve the expression *before* passing to createSubject so
22537
+ // the constructor receives a valid URI instead of raw data.
22538
+ const propMeta = metadata.properties[key];
22539
+ if (propMeta?.resolveLanguage && propMeta.resolveLanguage !== 'literal' && typeof value === 'object') {
22540
+ // Defer these properties — they need createExpression which may
22541
+ // fail inside a batch context on some languages. We'll set them
22542
+ // via setProperty after createSubject.
22543
+ deferredResolveLanguageProps.push(key);
22544
+ continue;
22545
+ }
22532
22546
  initialValues[key] = value;
22533
22547
  }
22534
22548
  }
@@ -22541,6 +22555,15 @@ FETCH links
22541
22555
  // When createSubject was skipped (no constructor actions), we must enable
22542
22556
  // property writing so that scalar values are persisted as links.
22543
22557
  await this.innerUpdate(!hasConstructor, batchId);
22558
+ // Now handle any deferred resolveLanguage properties that were excluded
22559
+ // from initialValues. setProperty will call createExpression to upload
22560
+ // the data to the appropriate language and store the resulting URI.
22561
+ for (const key of deferredResolveLanguageProps) {
22562
+ const value = this[key];
22563
+ if (value !== undefined && value !== null) {
22564
+ await this.setProperty(key, value, batchId);
22565
+ }
22566
+ }
22544
22567
  // If we got a batchId passed in, we let the caller decide when to commit.
22545
22568
  // We can't call getData() since the instance won't exist in the perspective
22546
22569
  // until the batch is committed.
@@ -2515,11 +2515,25 @@ FETCH links
2515
2515
  // entirely and let innerUpdate write the links directly.
2516
2516
  const metadata = this.constructor.getModelMetadata();
2517
2517
  const hasConstructor = Object.values(metadata.properties).some((p) => p.required || p.flag || p.initial !== undefined);
2518
+ // Track properties that have resolveLanguage (non-literal) so they can be
2519
+ // set via setProperty after createSubject (which doesn't resolve languages).
2520
+ const deferredResolveLanguageProps = [];
2518
2521
  if (hasConstructor) {
2519
2522
  // First filter out the properties that are not relations (arrays)
2520
2523
  const initialValues = {};
2521
2524
  for (const [key, value] of Object.entries(this)) {
2522
2525
  if (value !== undefined && value !== null && !(Array.isArray(value) && value.length > 0) && !value?.action) {
2526
+ // Check if this property requires language resolution (e.g. file storage).
2527
+ // If so, resolve the expression *before* passing to createSubject so
2528
+ // the constructor receives a valid URI instead of raw data.
2529
+ const propMeta = metadata.properties[key];
2530
+ if (propMeta?.resolveLanguage && propMeta.resolveLanguage !== 'literal' && typeof value === 'object') {
2531
+ // Defer these properties — they need createExpression which may
2532
+ // fail inside a batch context on some languages. We'll set them
2533
+ // via setProperty after createSubject.
2534
+ deferredResolveLanguageProps.push(key);
2535
+ continue;
2536
+ }
2523
2537
  initialValues[key] = value;
2524
2538
  }
2525
2539
  }
@@ -2532,6 +2546,15 @@ FETCH links
2532
2546
  // When createSubject was skipped (no constructor actions), we must enable
2533
2547
  // property writing so that scalar values are persisted as links.
2534
2548
  await this.innerUpdate(!hasConstructor, batchId);
2549
+ // Now handle any deferred resolveLanguage properties that were excluded
2550
+ // from initialValues. setProperty will call createExpression to upload
2551
+ // the data to the appropriate language and store the resulting URI.
2552
+ for (const key of deferredResolveLanguageProps) {
2553
+ const value = this[key];
2554
+ if (value !== undefined && value !== null) {
2555
+ await this.setProperty(key, value, batchId);
2556
+ }
2557
+ }
2535
2558
  // If we got a batchId passed in, we let the caller decide when to commit.
2536
2559
  // We can't call getData() since the instance won't exist in the perspective
2537
2560
  // until the batch is committed.
package/package.json CHANGED
@@ -58,7 +58,7 @@
58
58
  "ws": "8.13.0"
59
59
  },
60
60
  "patchedDependencies": {},
61
- "version": "0.12.0-rc1-dev.3",
61
+ "version": "0.12.0-rc1-dev.4",
62
62
  "scripts": {
63
63
  "build": "patch-package && tsc && pnpm run buildSchema && pnpm run bundle",
64
64
  "buildSchema": "tsx lib/src/buildSchema.js",
@@ -2996,11 +2996,26 @@ FETCH links
2996
2996
  (p) => p.required || p.flag || p.initial !== undefined
2997
2997
  );
2998
2998
 
2999
+ // Track properties that have resolveLanguage (non-literal) so they can be
3000
+ // set via setProperty after createSubject (which doesn't resolve languages).
3001
+ const deferredResolveLanguageProps: string[] = [];
3002
+
2999
3003
  if (hasConstructor) {
3000
3004
  // First filter out the properties that are not relations (arrays)
3001
3005
  const initialValues = {};
3002
3006
  for (const [key, value] of Object.entries(this)) {
3003
3007
  if (value !== undefined && value !== null && !(Array.isArray(value) && value.length > 0) && !value?.action) {
3008
+ // Check if this property requires language resolution (e.g. file storage).
3009
+ // If so, resolve the expression *before* passing to createSubject so
3010
+ // the constructor receives a valid URI instead of raw data.
3011
+ const propMeta = metadata.properties[key];
3012
+ if (propMeta?.resolveLanguage && propMeta.resolveLanguage !== 'literal' && typeof value === 'object') {
3013
+ // Defer these properties — they need createExpression which may
3014
+ // fail inside a batch context on some languages. We'll set them
3015
+ // via setProperty after createSubject.
3016
+ deferredResolveLanguageProps.push(key);
3017
+ continue;
3018
+ }
3004
3019
  initialValues[key] = value;
3005
3020
  }
3006
3021
  }
@@ -3022,6 +3037,16 @@ FETCH links
3022
3037
  // property writing so that scalar values are persisted as links.
3023
3038
  await this.innerUpdate(!hasConstructor, batchId)
3024
3039
 
3040
+ // Now handle any deferred resolveLanguage properties that were excluded
3041
+ // from initialValues. setProperty will call createExpression to upload
3042
+ // the data to the appropriate language and store the resulting URI.
3043
+ for (const key of deferredResolveLanguageProps) {
3044
+ const value = (this as any)[key];
3045
+ if (value !== undefined && value !== null) {
3046
+ await this.setProperty(key, value, batchId);
3047
+ }
3048
+ }
3049
+
3025
3050
  // If we got a batchId passed in, we let the caller decide when to commit.
3026
3051
  // We can't call getData() since the instance won't exist in the perspective
3027
3052
  // until the batch is committed.