@absolutejs/absolute 0.20.0-beta.14 → 0.20.0-beta.16

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/dist/cli/index.js CHANGED
@@ -6304,11 +6304,34 @@ var init_materializedBundle = __esm(() => {
6304
6304
  });
6305
6305
 
6306
6306
  // node_modules/@absolutejs/sync/dist/client/index.js
6307
- var RUNTIME_TRANSPORT, host, isRegistry = (value) => typeof value === "object" && value !== null && Array.isArray(Reflect.get(value, "installations")), registry, SyncLocalStoreSchemaError, positiveVersion = (value, label) => {
6307
+ var RUNTIME_TRANSPORT, host, isRegistry = (value) => typeof value === "object" && value !== null && Array.isArray(Reflect.get(value, "installations")), registry, SyncLocalDataPolicyError, SyncLocalStoreSchemaError, positiveVersion = (value, label) => {
6308
6308
  if (!Number.isSafeInteger(value) || value < 1)
6309
6309
  throw new SyncLocalStoreSchemaError("INVALID_PLAN", `${label} must be a positive safe integer`);
6310
6310
  return value;
6311
- }, isSchemaBundle = (schema) => ("components" in schema), normalizeSyncLocalSchemaComponents = (schema = { version: 1 }) => {
6311
+ }, isSchemaBundle = (schema) => ("components" in schema), validatePolicyMatch = (match, label) => {
6312
+ if (match.length === 0 || match.trim() !== match || /^\*+$/.test(match) || match.includes("**"))
6313
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.match must be an exact name or a non-empty glob without adjacent wildcards.`);
6314
+ }, validateSyncLocalDataPolicy = (policy, label = "localData") => {
6315
+ if (policy.maxBytesPerNamespace !== undefined && (!Number.isSafeInteger(policy.maxBytesPerNamespace) || policy.maxBytesPerNamespace < 1))
6316
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.maxBytesPerNamespace must be a positive safe integer.`);
6317
+ for (const [index, rule] of (policy.collections ?? []).entries()) {
6318
+ validatePolicyMatch(rule.match, `${label}.collections[${index}]`);
6319
+ if (rule.maxAgeMs !== undefined && (!Number.isSafeInteger(rule.maxAgeMs) || rule.maxAgeMs < 1))
6320
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.collections[${index}].maxAgeMs must be a positive safe integer.`);
6321
+ if (rule.persistence === "memory-only" && rule.protection === "required")
6322
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.collections[${index}] cannot require at-rest protection when it is memory-only.`);
6323
+ if (rule.sensitivity !== undefined && rule.sensitivity !== "public" && rule.protection !== "required" && rule.persistence !== "memory-only")
6324
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.collections[${index}] declares ${rule.sensitivity} data without required protection or memory-only persistence.`);
6325
+ }
6326
+ for (const [index, rule] of (policy.mutations ?? []).entries()) {
6327
+ validatePolicyMatch(rule.match, `${label}.mutations[${index}]`);
6328
+ if (rule.persistence === "memory-only" && rule.protection === "required")
6329
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.mutations[${index}] cannot require at-rest protection when it is memory-only.`);
6330
+ if (rule.sensitivity !== undefined && rule.sensitivity !== "public" && rule.protection !== "required" && rule.persistence !== "memory-only")
6331
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.mutations[${index}] declares ${rule.sensitivity} arguments without required protection.`);
6332
+ }
6333
+ return policy;
6334
+ }, normalizeSyncLocalSchemaComponents = (schema = { version: 1 }) => {
6312
6335
  const components = isSchemaBundle(schema) ? [...schema.components] : [{ ...schema, id: "@absolutejs/app" }];
6313
6336
  const ids = new Set;
6314
6337
  for (const component of components) {
@@ -6317,6 +6340,8 @@ var RUNTIME_TRANSPORT, host, isRegistry = (value) => typeof value === "object" &
6317
6340
  if (ids.has(component.id))
6318
6341
  throw new SyncLocalStoreSchemaError("INVALID_PLAN", `Sync schema component "${component.id}" is declared more than once`);
6319
6342
  ids.add(component.id);
6343
+ if (component.localData)
6344
+ validateSyncLocalDataPolicy(component.localData, `${component.id}.localData`);
6320
6345
  }
6321
6346
  return components.sort((a, b) => a.id.localeCompare(b.id));
6322
6347
  }, resolveSyncLocalSchemaComponents = (storedVersions, schema = { version: 1 }) => {
@@ -6374,6 +6399,14 @@ var init_client2 = __esm(() => {
6374
6399
  });
6375
6400
  return created;
6376
6401
  })();
6402
+ SyncLocalDataPolicyError = class SyncLocalDataPolicyError extends Error {
6403
+ code;
6404
+ constructor(code, message) {
6405
+ super(message);
6406
+ this.name = "SyncLocalDataPolicyError";
6407
+ this.code = code;
6408
+ }
6409
+ };
6377
6410
  SyncLocalStoreSchemaError = class SyncLocalStoreSchemaError extends Error {
6378
6411
  code;
6379
6412
  storedVersion;
@@ -6430,7 +6463,7 @@ var object = (value) => typeof value === "object" && value !== null && !Array.is
6430
6463
  if (!object(value))
6431
6464
  throw metadataError(id, detail);
6432
6465
  return value;
6433
- }, normalizeJsonValue = (value, id, field) => {
6466
+ }, unknownField = (record, key) => record[key], normalizeJsonValue = (value, id, field) => {
6434
6467
  if (value === null || typeof value === "string" || typeof value === "boolean")
6435
6468
  return value;
6436
6469
  if (typeof value === "number" && Number.isFinite(value))
@@ -6481,9 +6514,113 @@ var object = (value) => typeof value === "object" && value !== null && !Array.is
6481
6514
  operations: operations.map((entry, operationIndex) => operation(entry, id, operationIndex)),
6482
6515
  toVersion: positiveVersion2(Reflect.get(record, "toVersion"), id, `migration ${index}.toVersion`)
6483
6516
  };
6517
+ }, localDataPolicy = (value, id) => {
6518
+ const record = requireObject(value, id, "localData must be an object.");
6519
+ const allowed = new Set([
6520
+ "collections",
6521
+ "maxBytesPerNamespace",
6522
+ "mutations"
6523
+ ]);
6524
+ const unsupported = Object.keys(record).find((key) => !allowed.has(key));
6525
+ if (unsupported)
6526
+ throw metadataError(id, `localData.${unsupported} is not supported.`);
6527
+ const collectionRules = Reflect.get(record, "collections");
6528
+ const mutationRules = Reflect.get(record, "mutations");
6529
+ if (collectionRules !== undefined && !Array.isArray(collectionRules))
6530
+ throw metadataError(id, "localData.collections must be an array.");
6531
+ if (mutationRules !== undefined && !Array.isArray(mutationRules))
6532
+ throw metadataError(id, "localData.mutations must be an array.");
6533
+ const collections = Array.isArray(collectionRules) ? collectionRules.map((entry, index) => {
6534
+ const rule = requireObject(entry, id, `localData.collections[${index}] must be an object.`);
6535
+ const allowedRuleKeys = new Set([
6536
+ "evictionPriority",
6537
+ "match",
6538
+ "maxAgeMs",
6539
+ "onProtectionUnavailable",
6540
+ "persistence",
6541
+ "protection",
6542
+ "sensitivity"
6543
+ ]);
6544
+ const unsupportedRuleKey = Object.keys(rule).find((key) => !allowedRuleKeys.has(key));
6545
+ if (unsupportedRuleKey)
6546
+ throw metadataError(id, `localData.collections[${index}].${unsupportedRuleKey} is not supported.`);
6547
+ const match = nonEmpty(Reflect.get(rule, "match"), id, `localData.collections[${index}].match`);
6548
+ const persistence = unknownField(rule, "persistence");
6549
+ const sensitivity = unknownField(rule, "sensitivity");
6550
+ const protection = unknownField(rule, "protection");
6551
+ const onProtectionUnavailable = unknownField(rule, "onProtectionUnavailable");
6552
+ const evictionPriority = unknownField(rule, "evictionPriority");
6553
+ const maxAge = unknownField(rule, "maxAgeMs");
6554
+ if (persistence !== undefined && persistence !== "durable" && persistence !== "memory-only")
6555
+ throw metadataError(id, `localData.collections[${index}].persistence is invalid.`);
6556
+ if (sensitivity !== undefined && sensitivity !== "public" && sensitivity !== "private" && sensitivity !== "secret")
6557
+ throw metadataError(id, `localData.collections[${index}].sensitivity is invalid.`);
6558
+ if (protection !== undefined && protection !== "none" && protection !== "required")
6559
+ throw metadataError(id, `localData.collections[${index}].protection is invalid.`);
6560
+ if (onProtectionUnavailable !== undefined && onProtectionUnavailable !== "error" && onProtectionUnavailable !== "memory-only")
6561
+ throw metadataError(id, `localData.collections[${index}].onProtectionUnavailable is invalid.`);
6562
+ if (evictionPriority !== undefined && evictionPriority !== "critical" && evictionPriority !== "normal" && evictionPriority !== "disposable")
6563
+ throw metadataError(id, `localData.collections[${index}].evictionPriority is invalid.`);
6564
+ return {
6565
+ match,
6566
+ ...sensitivity ? { sensitivity } : {},
6567
+ ...persistence ? { persistence } : {},
6568
+ ...protection ? { protection } : {},
6569
+ ...onProtectionUnavailable ? {
6570
+ onProtectionUnavailable
6571
+ } : {},
6572
+ ...evictionPriority ? { evictionPriority } : {},
6573
+ ...maxAge === undefined ? {} : {
6574
+ maxAgeMs: positiveVersion2(maxAge, id, `localData.collections[${index}].maxAgeMs`)
6575
+ }
6576
+ };
6577
+ }) : undefined;
6578
+ const mutations = Array.isArray(mutationRules) ? mutationRules.map((entry, index) => {
6579
+ const rule = requireObject(entry, id, `localData.mutations[${index}] must be an object.`);
6580
+ const allowedRuleKeys = new Set([
6581
+ "match",
6582
+ "onProtectionUnavailable",
6583
+ "persistence",
6584
+ "protection",
6585
+ "sensitivity"
6586
+ ]);
6587
+ const unsupportedRuleKey = Object.keys(rule).find((key) => !allowedRuleKeys.has(key));
6588
+ if (unsupportedRuleKey)
6589
+ throw metadataError(id, `localData.mutations[${index}].${unsupportedRuleKey} is not supported.`);
6590
+ const protection = unknownField(rule, "protection");
6591
+ const sensitivity = unknownField(rule, "sensitivity");
6592
+ const persistence = unknownField(rule, "persistence");
6593
+ const onProtectionUnavailable = unknownField(rule, "onProtectionUnavailable");
6594
+ if (protection !== undefined && protection !== "none" && protection !== "required")
6595
+ throw metadataError(id, `localData.mutations[${index}].protection is invalid.`);
6596
+ if (sensitivity !== undefined && sensitivity !== "public" && sensitivity !== "private" && sensitivity !== "secret")
6597
+ throw metadataError(id, `localData.mutations[${index}].sensitivity is invalid.`);
6598
+ if (onProtectionUnavailable !== undefined && onProtectionUnavailable !== "error" && onProtectionUnavailable !== "memory-only")
6599
+ throw metadataError(id, `localData.mutations[${index}].onProtectionUnavailable is invalid.`);
6600
+ if (persistence !== undefined && persistence !== "durable" && persistence !== "memory-only")
6601
+ throw metadataError(id, `localData.mutations[${index}].persistence is invalid.`);
6602
+ return {
6603
+ match: nonEmpty(Reflect.get(rule, "match"), id, `localData.mutations[${index}].match`),
6604
+ ...sensitivity ? { sensitivity } : {},
6605
+ ...onProtectionUnavailable ? { onProtectionUnavailable } : {},
6606
+ ...persistence ? {
6607
+ persistence
6608
+ } : {},
6609
+ ...protection ? { protection } : {}
6610
+ };
6611
+ }) : undefined;
6612
+ const quota = Reflect.get(record, "maxBytesPerNamespace");
6613
+ return {
6614
+ ...collections ? { collections } : {},
6615
+ ...mutations ? { mutations } : {},
6616
+ ...quota === undefined ? {} : {
6617
+ maxBytesPerNamespace: positiveVersion2(quota, id, "localData.maxBytesPerNamespace")
6618
+ }
6619
+ };
6484
6620
  }, component = (id, value) => {
6485
6621
  const record = requireObject(value, id, "localSchema must be an object.");
6486
6622
  const allowed = new Set([
6623
+ "localData",
6487
6624
  "migrations",
6488
6625
  "minimumCompatibleVersion",
6489
6626
  "version"
@@ -6495,11 +6632,13 @@ var object = (value) => typeof value === "object" && value !== null && !Array.is
6495
6632
  const declaredMinimum = Reflect.get(record, "minimumCompatibleVersion");
6496
6633
  const minimumCompatibleVersion = declaredMinimum === undefined ? Math.max(1, version2 - 2) : positiveVersion2(declaredMinimum, id, "minimumCompatibleVersion");
6497
6634
  const declaredMigrations = Reflect.get(record, "migrations");
6635
+ const declaredLocalData = Reflect.get(record, "localData");
6498
6636
  if (declaredMigrations !== undefined && !Array.isArray(declaredMigrations))
6499
6637
  throw metadataError(id, "migrations must be an array.");
6500
6638
  const migrations = Array.isArray(declaredMigrations) ? declaredMigrations : undefined;
6501
6639
  return {
6502
6640
  id,
6641
+ ...declaredLocalData === undefined ? {} : { localData: localDataPolicy(declaredLocalData, id) },
6503
6642
  minimumCompatibleVersion,
6504
6643
  ...Array.isArray(migrations) ? {
6505
6644
  migrations: migrations.map((entry, index) => migration(entry, id, index))
@@ -16835,7 +16974,13 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
16835
16974
  try {
16836
16975
  const schema = discoverAbsoluteSyncSchema(projectRoot);
16837
16976
  const versions = schema.components.map((component2) => `${component2.id}@${component2.version}`).join(", ");
16838
- return pass("sync.storage-schema", `Generated offline schema is compatible: ${versions}.`, manifestPath);
16977
+ const collectionRules = schema.components.flatMap((component2) => component2.localData?.collections ?? []);
16978
+ const mutationRules = schema.components.flatMap((component2) => component2.localData?.mutations ?? []);
16979
+ const protectedCount = [...collectionRules, ...mutationRules].filter((rule) => rule.protection === "required").length;
16980
+ const memoryOnlyCount = [...collectionRules, ...mutationRules].filter((rule) => rule.persistence === "memory-only" || rule.onProtectionUnavailable === "memory-only").length;
16981
+ const quotas = schema.components.map((component2) => component2.localData?.maxBytesPerNamespace).filter((value) => value !== undefined);
16982
+ const policy = `${collectionRules.length} collection rule(s), ${mutationRules.length} mutation rule(s), ${protectedCount} encryption-required, ${memoryOnlyCount} memory-only fallback(s)${quotas.length > 0 ? `, ${Math.min(...quotas)}-byte effective quota` : ", no logical quota"}`;
16983
+ return pass("sync.storage-schema", `Generated offline schema is compatible: ${versions}; ${policy}.`, manifestPath);
16839
16984
  } catch (error) {
16840
16985
  return fail5("sync.storage-schema", error instanceof Error ? error.message : "Generated offline schema metadata is invalid.", manifestPath, "Fix absolutejs.sync.localSchema metadata in the named app or package before releasing.");
16841
16986
  }
@@ -18367,7 +18512,7 @@ var init_mobile = __esm(() => {
18367
18512
  "@absolutejs/devices-capacitor@0.1.3"
18368
18513
  ];
18369
18514
  CAPACITOR_SYNC_PACKAGE_SPECS = [
18370
- "@absolutejs/sync-capacitor@0.6.1",
18515
+ "@absolutejs/sync-capacitor@0.7.0",
18371
18516
  "@capacitor-community/sqlite@8.1.1"
18372
18517
  ];
18373
18518
  });
package/dist/index.js CHANGED
@@ -13199,11 +13199,34 @@ var isTestSourcePath = (file2) => {
13199
13199
  };
13200
13200
 
13201
13201
  // node_modules/@absolutejs/sync/dist/client/index.js
13202
- var RUNTIME_TRANSPORT, host, isRegistry = (value) => typeof value === "object" && value !== null && Array.isArray(Reflect.get(value, "installations")), registry, SyncLocalStoreSchemaError, positiveVersion = (value, label) => {
13202
+ var RUNTIME_TRANSPORT, host, isRegistry = (value) => typeof value === "object" && value !== null && Array.isArray(Reflect.get(value, "installations")), registry, SyncLocalDataPolicyError, SyncLocalStoreSchemaError, positiveVersion = (value, label) => {
13203
13203
  if (!Number.isSafeInteger(value) || value < 1)
13204
13204
  throw new SyncLocalStoreSchemaError("INVALID_PLAN", `${label} must be a positive safe integer`);
13205
13205
  return value;
13206
- }, isSchemaBundle = (schema) => ("components" in schema), normalizeSyncLocalSchemaComponents = (schema = { version: 1 }) => {
13206
+ }, isSchemaBundle = (schema) => ("components" in schema), validatePolicyMatch = (match, label) => {
13207
+ if (match.length === 0 || match.trim() !== match || /^\*+$/.test(match) || match.includes("**"))
13208
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.match must be an exact name or a non-empty glob without adjacent wildcards.`);
13209
+ }, validateSyncLocalDataPolicy = (policy, label = "localData") => {
13210
+ if (policy.maxBytesPerNamespace !== undefined && (!Number.isSafeInteger(policy.maxBytesPerNamespace) || policy.maxBytesPerNamespace < 1))
13211
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.maxBytesPerNamespace must be a positive safe integer.`);
13212
+ for (const [index, rule] of (policy.collections ?? []).entries()) {
13213
+ validatePolicyMatch(rule.match, `${label}.collections[${index}]`);
13214
+ if (rule.maxAgeMs !== undefined && (!Number.isSafeInteger(rule.maxAgeMs) || rule.maxAgeMs < 1))
13215
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.collections[${index}].maxAgeMs must be a positive safe integer.`);
13216
+ if (rule.persistence === "memory-only" && rule.protection === "required")
13217
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.collections[${index}] cannot require at-rest protection when it is memory-only.`);
13218
+ if (rule.sensitivity !== undefined && rule.sensitivity !== "public" && rule.protection !== "required" && rule.persistence !== "memory-only")
13219
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.collections[${index}] declares ${rule.sensitivity} data without required protection or memory-only persistence.`);
13220
+ }
13221
+ for (const [index, rule] of (policy.mutations ?? []).entries()) {
13222
+ validatePolicyMatch(rule.match, `${label}.mutations[${index}]`);
13223
+ if (rule.persistence === "memory-only" && rule.protection === "required")
13224
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.mutations[${index}] cannot require at-rest protection when it is memory-only.`);
13225
+ if (rule.sensitivity !== undefined && rule.sensitivity !== "public" && rule.protection !== "required" && rule.persistence !== "memory-only")
13226
+ throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.mutations[${index}] declares ${rule.sensitivity} arguments without required protection.`);
13227
+ }
13228
+ return policy;
13229
+ }, normalizeSyncLocalSchemaComponents = (schema = { version: 1 }) => {
13207
13230
  const components = isSchemaBundle(schema) ? [...schema.components] : [{ ...schema, id: "@absolutejs/app" }];
13208
13231
  const ids = new Set;
13209
13232
  for (const component of components) {
@@ -13212,6 +13235,8 @@ var RUNTIME_TRANSPORT, host, isRegistry = (value) => typeof value === "object" &
13212
13235
  if (ids.has(component.id))
13213
13236
  throw new SyncLocalStoreSchemaError("INVALID_PLAN", `Sync schema component "${component.id}" is declared more than once`);
13214
13237
  ids.add(component.id);
13238
+ if (component.localData)
13239
+ validateSyncLocalDataPolicy(component.localData, `${component.id}.localData`);
13215
13240
  }
13216
13241
  return components.sort((a, b2) => a.id.localeCompare(b2.id));
13217
13242
  }, resolveSyncLocalSchemaComponents = (storedVersions, schema = { version: 1 }) => {
@@ -13269,6 +13294,14 @@ var init_client = __esm(() => {
13269
13294
  });
13270
13295
  return created;
13271
13296
  })();
13297
+ SyncLocalDataPolicyError = class SyncLocalDataPolicyError extends Error {
13298
+ code;
13299
+ constructor(code, message) {
13300
+ super(message);
13301
+ this.name = "SyncLocalDataPolicyError";
13302
+ this.code = code;
13303
+ }
13304
+ };
13272
13305
  SyncLocalStoreSchemaError = class SyncLocalStoreSchemaError extends Error {
13273
13306
  code;
13274
13307
  storedVersion;
@@ -13325,7 +13358,7 @@ var object = (value) => typeof value === "object" && value !== null && !Array.is
13325
13358
  if (!object(value))
13326
13359
  throw metadataError(id, detail);
13327
13360
  return value;
13328
- }, normalizeJsonValue2 = (value, id, field) => {
13361
+ }, unknownField = (record, key) => record[key], normalizeJsonValue2 = (value, id, field) => {
13329
13362
  if (value === null || typeof value === "string" || typeof value === "boolean")
13330
13363
  return value;
13331
13364
  if (typeof value === "number" && Number.isFinite(value))
@@ -13376,9 +13409,113 @@ var object = (value) => typeof value === "object" && value !== null && !Array.is
13376
13409
  operations: operations.map((entry, operationIndex) => operation(entry, id, operationIndex)),
13377
13410
  toVersion: positiveVersion2(Reflect.get(record, "toVersion"), id, `migration ${index}.toVersion`)
13378
13411
  };
13412
+ }, localDataPolicy = (value, id) => {
13413
+ const record = requireObject(value, id, "localData must be an object.");
13414
+ const allowed = new Set([
13415
+ "collections",
13416
+ "maxBytesPerNamespace",
13417
+ "mutations"
13418
+ ]);
13419
+ const unsupported = Object.keys(record).find((key) => !allowed.has(key));
13420
+ if (unsupported)
13421
+ throw metadataError(id, `localData.${unsupported} is not supported.`);
13422
+ const collectionRules = Reflect.get(record, "collections");
13423
+ const mutationRules = Reflect.get(record, "mutations");
13424
+ if (collectionRules !== undefined && !Array.isArray(collectionRules))
13425
+ throw metadataError(id, "localData.collections must be an array.");
13426
+ if (mutationRules !== undefined && !Array.isArray(mutationRules))
13427
+ throw metadataError(id, "localData.mutations must be an array.");
13428
+ const collections = Array.isArray(collectionRules) ? collectionRules.map((entry, index) => {
13429
+ const rule = requireObject(entry, id, `localData.collections[${index}] must be an object.`);
13430
+ const allowedRuleKeys = new Set([
13431
+ "evictionPriority",
13432
+ "match",
13433
+ "maxAgeMs",
13434
+ "onProtectionUnavailable",
13435
+ "persistence",
13436
+ "protection",
13437
+ "sensitivity"
13438
+ ]);
13439
+ const unsupportedRuleKey = Object.keys(rule).find((key) => !allowedRuleKeys.has(key));
13440
+ if (unsupportedRuleKey)
13441
+ throw metadataError(id, `localData.collections[${index}].${unsupportedRuleKey} is not supported.`);
13442
+ const match = nonEmpty(Reflect.get(rule, "match"), id, `localData.collections[${index}].match`);
13443
+ const persistence = unknownField(rule, "persistence");
13444
+ const sensitivity = unknownField(rule, "sensitivity");
13445
+ const protection = unknownField(rule, "protection");
13446
+ const onProtectionUnavailable = unknownField(rule, "onProtectionUnavailable");
13447
+ const evictionPriority = unknownField(rule, "evictionPriority");
13448
+ const maxAge = unknownField(rule, "maxAgeMs");
13449
+ if (persistence !== undefined && persistence !== "durable" && persistence !== "memory-only")
13450
+ throw metadataError(id, `localData.collections[${index}].persistence is invalid.`);
13451
+ if (sensitivity !== undefined && sensitivity !== "public" && sensitivity !== "private" && sensitivity !== "secret")
13452
+ throw metadataError(id, `localData.collections[${index}].sensitivity is invalid.`);
13453
+ if (protection !== undefined && protection !== "none" && protection !== "required")
13454
+ throw metadataError(id, `localData.collections[${index}].protection is invalid.`);
13455
+ if (onProtectionUnavailable !== undefined && onProtectionUnavailable !== "error" && onProtectionUnavailable !== "memory-only")
13456
+ throw metadataError(id, `localData.collections[${index}].onProtectionUnavailable is invalid.`);
13457
+ if (evictionPriority !== undefined && evictionPriority !== "critical" && evictionPriority !== "normal" && evictionPriority !== "disposable")
13458
+ throw metadataError(id, `localData.collections[${index}].evictionPriority is invalid.`);
13459
+ return {
13460
+ match,
13461
+ ...sensitivity ? { sensitivity } : {},
13462
+ ...persistence ? { persistence } : {},
13463
+ ...protection ? { protection } : {},
13464
+ ...onProtectionUnavailable ? {
13465
+ onProtectionUnavailable
13466
+ } : {},
13467
+ ...evictionPriority ? { evictionPriority } : {},
13468
+ ...maxAge === undefined ? {} : {
13469
+ maxAgeMs: positiveVersion2(maxAge, id, `localData.collections[${index}].maxAgeMs`)
13470
+ }
13471
+ };
13472
+ }) : undefined;
13473
+ const mutations = Array.isArray(mutationRules) ? mutationRules.map((entry, index) => {
13474
+ const rule = requireObject(entry, id, `localData.mutations[${index}] must be an object.`);
13475
+ const allowedRuleKeys = new Set([
13476
+ "match",
13477
+ "onProtectionUnavailable",
13478
+ "persistence",
13479
+ "protection",
13480
+ "sensitivity"
13481
+ ]);
13482
+ const unsupportedRuleKey = Object.keys(rule).find((key) => !allowedRuleKeys.has(key));
13483
+ if (unsupportedRuleKey)
13484
+ throw metadataError(id, `localData.mutations[${index}].${unsupportedRuleKey} is not supported.`);
13485
+ const protection = unknownField(rule, "protection");
13486
+ const sensitivity = unknownField(rule, "sensitivity");
13487
+ const persistence = unknownField(rule, "persistence");
13488
+ const onProtectionUnavailable = unknownField(rule, "onProtectionUnavailable");
13489
+ if (protection !== undefined && protection !== "none" && protection !== "required")
13490
+ throw metadataError(id, `localData.mutations[${index}].protection is invalid.`);
13491
+ if (sensitivity !== undefined && sensitivity !== "public" && sensitivity !== "private" && sensitivity !== "secret")
13492
+ throw metadataError(id, `localData.mutations[${index}].sensitivity is invalid.`);
13493
+ if (onProtectionUnavailable !== undefined && onProtectionUnavailable !== "error" && onProtectionUnavailable !== "memory-only")
13494
+ throw metadataError(id, `localData.mutations[${index}].onProtectionUnavailable is invalid.`);
13495
+ if (persistence !== undefined && persistence !== "durable" && persistence !== "memory-only")
13496
+ throw metadataError(id, `localData.mutations[${index}].persistence is invalid.`);
13497
+ return {
13498
+ match: nonEmpty(Reflect.get(rule, "match"), id, `localData.mutations[${index}].match`),
13499
+ ...sensitivity ? { sensitivity } : {},
13500
+ ...onProtectionUnavailable ? { onProtectionUnavailable } : {},
13501
+ ...persistence ? {
13502
+ persistence
13503
+ } : {},
13504
+ ...protection ? { protection } : {}
13505
+ };
13506
+ }) : undefined;
13507
+ const quota = Reflect.get(record, "maxBytesPerNamespace");
13508
+ return {
13509
+ ...collections ? { collections } : {},
13510
+ ...mutations ? { mutations } : {},
13511
+ ...quota === undefined ? {} : {
13512
+ maxBytesPerNamespace: positiveVersion2(quota, id, "localData.maxBytesPerNamespace")
13513
+ }
13514
+ };
13379
13515
  }, component = (id, value) => {
13380
13516
  const record = requireObject(value, id, "localSchema must be an object.");
13381
13517
  const allowed = new Set([
13518
+ "localData",
13382
13519
  "migrations",
13383
13520
  "minimumCompatibleVersion",
13384
13521
  "version"
@@ -13390,11 +13527,13 @@ var object = (value) => typeof value === "object" && value !== null && !Array.is
13390
13527
  const declaredMinimum = Reflect.get(record, "minimumCompatibleVersion");
13391
13528
  const minimumCompatibleVersion = declaredMinimum === undefined ? Math.max(1, version - 2) : positiveVersion2(declaredMinimum, id, "minimumCompatibleVersion");
13392
13529
  const declaredMigrations = Reflect.get(record, "migrations");
13530
+ const declaredLocalData = Reflect.get(record, "localData");
13393
13531
  if (declaredMigrations !== undefined && !Array.isArray(declaredMigrations))
13394
13532
  throw metadataError(id, "migrations must be an array.");
13395
13533
  const migrations = Array.isArray(declaredMigrations) ? declaredMigrations : undefined;
13396
13534
  return {
13397
13535
  id,
13536
+ ...declaredLocalData === undefined ? {} : { localData: localDataPolicy(declaredLocalData, id) },
13398
13537
  minimumCompatibleVersion,
13399
13538
  ...Array.isArray(migrations) ? {
13400
13539
  migrations: migrations.map((entry, index) => migration(entry, id, index))
@@ -40248,5 +40387,5 @@ export {
40248
40387
  ANGULAR_INIT_TIMEOUT_MS
40249
40388
  };
40250
40389
 
40251
- //# debugId=4D6C6E5D8BEF467C64756E2164756E21
40390
+ //# debugId=FF975832AE5A306264756E2164756E21
40252
40391
  //# sourceMappingURL=index.js.map