@resourcexjs/core 2.8.0 → 2.10.0

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/index.js CHANGED
@@ -14647,37 +14647,46 @@ async function extract(rxa) {
14647
14647
  return files;
14648
14648
  }
14649
14649
  // src/model/format.ts
14650
- function format(rxl) {
14650
+ function format(rxi) {
14651
14651
  let result = "";
14652
- if (rxl.registry) {
14653
- result += `${rxl.registry}/`;
14652
+ if (rxi.registry) {
14653
+ result += `${rxi.registry}/`;
14654
14654
  }
14655
- if (rxl.path) {
14656
- result += `${rxl.path}/`;
14655
+ if (rxi.path) {
14656
+ result += `${rxi.path}/`;
14657
14657
  }
14658
- result += rxl.name;
14659
- if (rxl.tag && rxl.tag !== "latest") {
14660
- result += `:${rxl.tag}`;
14658
+ result += rxi.name;
14659
+ if (rxi.tag && rxi.tag !== "latest") {
14660
+ result += `:${rxi.tag}`;
14661
14661
  }
14662
14662
  return result;
14663
14663
  }
14664
14664
  // src/model/locate.ts
14665
14665
  function locate(rxm) {
14666
14666
  return {
14667
- registry: rxm.registry,
14668
- path: rxm.path,
14669
- name: rxm.name,
14670
- tag: rxm.tag
14667
+ registry: rxm.definition.registry,
14668
+ path: rxm.definition.path,
14669
+ name: rxm.definition.name,
14670
+ tag: rxm.definition.tag
14671
14671
  };
14672
14672
  }
14673
14673
  // src/model/manifest.ts
14674
14674
  function manifest(rxd) {
14675
14675
  return {
14676
- registry: rxd.registry,
14677
- path: rxd.path,
14678
- name: rxd.name,
14679
- type: rxd.type,
14680
- tag: rxd.tag ?? "latest"
14676
+ definition: {
14677
+ name: rxd.name,
14678
+ type: rxd.type,
14679
+ tag: rxd.tag ?? "latest",
14680
+ registry: rxd.registry,
14681
+ path: rxd.path,
14682
+ description: rxd.description,
14683
+ author: rxd.author,
14684
+ license: rxd.license,
14685
+ keywords: rxd.keywords,
14686
+ repository: rxd.repository
14687
+ },
14688
+ archive: {},
14689
+ source: {}
14681
14690
  };
14682
14691
  }
14683
14692
  // src/model/parse.ts
@@ -14782,9 +14791,9 @@ function parse5(locator) {
14782
14791
  }
14783
14792
  // src/model/resource.ts
14784
14793
  function resource(rxm, rxa) {
14785
- const rxl = locate(rxm);
14794
+ const rxi = locate(rxm);
14786
14795
  return {
14787
- locator: rxl,
14796
+ identifier: rxi,
14788
14797
  manifest: rxm,
14789
14798
  archive: rxa
14790
14799
  };
@@ -15193,17 +15202,17 @@ class RegistryMiddleware {
15193
15202
  constructor(inner) {
15194
15203
  this.inner = inner;
15195
15204
  }
15196
- get(rxl) {
15197
- return this.inner.get(rxl);
15205
+ get(rxi) {
15206
+ return this.inner.get(rxi);
15198
15207
  }
15199
15208
  put(rxr) {
15200
15209
  return this.inner.put(rxr);
15201
15210
  }
15202
- has(rxl) {
15203
- return this.inner.has(rxl);
15211
+ has(rxi) {
15212
+ return this.inner.has(rxi);
15204
15213
  }
15205
- remove(rxl) {
15206
- return this.inner.remove(rxl);
15214
+ remove(rxi) {
15215
+ return this.inner.remove(rxi);
15207
15216
  }
15208
15217
  list(options) {
15209
15218
  return this.inner.list(options);
@@ -15218,12 +15227,12 @@ class RegistryValidation extends RegistryMiddleware {
15218
15227
  this.trustedRegistry = trustedRegistry;
15219
15228
  }
15220
15229
  validateRegistry(rxr) {
15221
- if (rxr.manifest.registry !== this.trustedRegistry) {
15222
- throw new RegistryError(`Untrusted registry: resource claims "${rxr.manifest.registry}" but registry only trusts "${this.trustedRegistry}"`);
15230
+ if (rxr.manifest.definition.registry !== this.trustedRegistry) {
15231
+ throw new RegistryError(`Untrusted registry: resource claims "${rxr.manifest.definition.registry}" but registry only trusts "${this.trustedRegistry}"`);
15223
15232
  }
15224
15233
  }
15225
- async get(rxl) {
15226
- const rxr = await this.inner.get(rxl);
15234
+ async get(rxi) {
15235
+ const rxr = await this.inner.get(rxi);
15227
15236
  this.validateRegistry(rxr);
15228
15237
  return rxr;
15229
15238
  }
@@ -15252,23 +15261,31 @@ class CASRegistry {
15252
15261
  }
15253
15262
  return tag;
15254
15263
  }
15255
- async get(rxl) {
15256
- const tag = await this.resolveTag(rxl.name, rxl.tag ?? "latest", rxl.registry);
15257
- const storedRxm = await this.rxmStore.get(rxl.name, tag, rxl.registry);
15264
+ async get(rxi) {
15265
+ const tag = await this.resolveTag(rxi.name, rxi.tag ?? "latest", rxi.registry);
15266
+ const storedRxm = await this.rxmStore.get(rxi.name, tag, rxi.registry);
15258
15267
  if (!storedRxm) {
15259
- throw new RegistryError(`Resource not found: ${format(rxl)}`);
15268
+ throw new RegistryError(`Resource not found: ${format(rxi)}`);
15260
15269
  }
15261
15270
  const files = {};
15262
15271
  for (const [filename, digest] of Object.entries(storedRxm.files)) {
15263
15272
  files[filename] = await this.rxaStore.get(digest);
15264
15273
  }
15265
15274
  const rxm = {
15266
- registry: storedRxm.registry,
15267
- path: storedRxm.path,
15268
- name: storedRxm.name,
15269
- type: storedRxm.type,
15270
- tag: storedRxm.tag,
15271
- files: Object.keys(storedRxm.files)
15275
+ definition: {
15276
+ registry: storedRxm.registry,
15277
+ path: storedRxm.path,
15278
+ name: storedRxm.name,
15279
+ type: storedRxm.type,
15280
+ tag: storedRxm.tag,
15281
+ description: storedRxm.description,
15282
+ author: storedRxm.author,
15283
+ license: storedRxm.license,
15284
+ keywords: storedRxm.keywords,
15285
+ repository: storedRxm.repository
15286
+ },
15287
+ archive: {},
15288
+ source: {}
15272
15289
  };
15273
15290
  const rxa = await archive(files);
15274
15291
  return resource(rxm, rxa);
@@ -15281,25 +15298,30 @@ class CASRegistry {
15281
15298
  fileDigests[filename] = digest;
15282
15299
  }
15283
15300
  const storedRxm = {
15284
- registry: rxr.manifest.registry,
15285
- path: rxr.manifest.path,
15286
- name: rxr.manifest.name,
15287
- type: rxr.manifest.type,
15288
- tag: rxr.manifest.tag,
15301
+ registry: rxr.manifest.definition.registry,
15302
+ path: rxr.manifest.definition.path,
15303
+ name: rxr.manifest.definition.name,
15304
+ type: rxr.manifest.definition.type,
15305
+ tag: rxr.manifest.definition.tag,
15306
+ description: rxr.manifest.definition.description,
15307
+ author: rxr.manifest.definition.author,
15308
+ license: rxr.manifest.definition.license,
15309
+ keywords: rxr.manifest.definition.keywords,
15310
+ repository: rxr.manifest.definition.repository,
15289
15311
  files: fileDigests,
15290
15312
  createdAt: new Date,
15291
15313
  updatedAt: new Date
15292
15314
  };
15293
15315
  await this.rxmStore.put(storedRxm);
15294
- await this.rxmStore.setLatest(rxr.manifest.name, rxr.manifest.tag, rxr.manifest.registry);
15316
+ await this.rxmStore.setLatest(rxr.manifest.definition.name, rxr.manifest.definition.tag, rxr.manifest.definition.registry);
15295
15317
  }
15296
- async has(rxl) {
15297
- const tag = await this.resolveTag(rxl.name, rxl.tag ?? "latest", rxl.registry);
15298
- return this.rxmStore.has(rxl.name, tag, rxl.registry);
15318
+ async has(rxi) {
15319
+ const tag = await this.resolveTag(rxi.name, rxi.tag ?? "latest", rxi.registry);
15320
+ return this.rxmStore.has(rxi.name, tag, rxi.registry);
15299
15321
  }
15300
- async remove(rxl) {
15301
- const tag = rxl.tag ?? "latest";
15302
- await this.rxmStore.delete(rxl.name, tag, rxl.registry);
15322
+ async remove(rxi) {
15323
+ const tag = rxi.tag ?? "latest";
15324
+ await this.rxmStore.delete(rxi.name, tag, rxi.registry);
15303
15325
  }
15304
15326
  async list(options) {
15305
15327
  const { query, limit, offset = 0 } = options ?? {};
@@ -15363,14 +15385,14 @@ class LinkedRegistry {
15363
15385
  constructor(basePath) {
15364
15386
  this.basePath = basePath;
15365
15387
  }
15366
- buildLinkPath(rxl) {
15367
- const registry2 = rxl.registry ?? "localhost";
15368
- const tag = rxl.tag ?? "latest";
15388
+ buildLinkPath(rxi) {
15389
+ const registry2 = rxi.registry ?? "localhost";
15390
+ const tag = rxi.tag ?? "latest";
15369
15391
  let linkPath = join3(this.basePath, registry2);
15370
- if (rxl.path) {
15371
- linkPath = join3(linkPath, rxl.path);
15392
+ if (rxi.path) {
15393
+ linkPath = join3(linkPath, rxi.path);
15372
15394
  }
15373
- return join3(linkPath, rxl.name, tag);
15395
+ return join3(linkPath, rxi.name, tag);
15374
15396
  }
15375
15397
  async isSymlink(path) {
15376
15398
  try {
@@ -15380,10 +15402,10 @@ class LinkedRegistry {
15380
15402
  return false;
15381
15403
  }
15382
15404
  }
15383
- async get(rxl) {
15384
- const linkPath = this.buildLinkPath(rxl);
15405
+ async get(rxi) {
15406
+ const linkPath = this.buildLinkPath(rxi);
15385
15407
  if (!await this.isSymlink(linkPath)) {
15386
- throw new RegistryError(`Linked resource not found: ${format(rxl)}`);
15408
+ throw new RegistryError(`Linked resource not found: ${format(rxi)}`);
15387
15409
  }
15388
15410
  const targetPath = await readlink(linkPath);
15389
15411
  return loadResource(targetPath);
@@ -15391,29 +15413,29 @@ class LinkedRegistry {
15391
15413
  async put(_rxr) {
15392
15414
  throw new RegistryError("LinkedRegistry does not support put(). Use link() instead.");
15393
15415
  }
15394
- async has(rxl) {
15395
- const linkPath = this.buildLinkPath(rxl);
15416
+ async has(rxi) {
15417
+ const linkPath = this.buildLinkPath(rxi);
15396
15418
  return this.isSymlink(linkPath);
15397
15419
  }
15398
- async remove(rxl) {
15399
- const linkPath = this.buildLinkPath(rxl);
15420
+ async remove(rxi) {
15421
+ const linkPath = this.buildLinkPath(rxi);
15400
15422
  if (await this.isSymlink(linkPath)) {
15401
15423
  await rm(linkPath);
15402
15424
  }
15403
15425
  }
15404
15426
  async list(options) {
15405
15427
  const { query, limit, offset = 0 } = options ?? {};
15406
- const locators = [];
15428
+ const identifiers = [];
15407
15429
  try {
15408
- await this.scanSymlinks(this.basePath, "", locators);
15430
+ await this.scanSymlinks(this.basePath, "", identifiers);
15409
15431
  } catch {
15410
15432
  return [];
15411
15433
  }
15412
- let filtered = locators;
15434
+ let filtered = identifiers;
15413
15435
  if (query) {
15414
15436
  const lowerQuery = query.toLowerCase();
15415
- filtered = locators.filter((rxl) => {
15416
- const searchText = `${rxl.registry ?? ""} ${rxl.path ?? ""} ${rxl.name}`.toLowerCase();
15437
+ filtered = identifiers.filter((rxi) => {
15438
+ const searchText = `${rxi.registry ?? ""} ${rxi.path ?? ""} ${rxi.name}`.toLowerCase();
15417
15439
  return searchText.includes(lowerQuery);
15418
15440
  });
15419
15441
  }
@@ -15425,7 +15447,7 @@ class LinkedRegistry {
15425
15447
  }
15426
15448
  async link(devPath) {
15427
15449
  const rxr = await loadResource(devPath);
15428
- const linkPath = this.buildLinkPath(rxr.locator);
15450
+ const linkPath = this.buildLinkPath(rxr.identifier);
15429
15451
  try {
15430
15452
  const stats = await lstat(linkPath);
15431
15453
  if (stats.isSymbolicLink() || stats.isDirectory()) {
@@ -15436,12 +15458,12 @@ class LinkedRegistry {
15436
15458
  await mkdir(parentPath, { recursive: true });
15437
15459
  const absolutePath = resolvePath(devPath);
15438
15460
  await symlink(absolutePath, linkPath);
15439
- return rxr.locator;
15461
+ return rxr.identifier;
15440
15462
  }
15441
- async unlink(rxl) {
15442
- return this.remove(rxl);
15463
+ async unlink(rxi) {
15464
+ return this.remove(rxi);
15443
15465
  }
15444
- async scanSymlinks(dirPath, relativePath, locators) {
15466
+ async scanSymlinks(dirPath, relativePath, identifiers) {
15445
15467
  let entries;
15446
15468
  try {
15447
15469
  entries = await readdir3(dirPath);
@@ -15454,17 +15476,17 @@ class LinkedRegistry {
15454
15476
  try {
15455
15477
  const stats = await lstat(fullPath);
15456
15478
  if (stats.isSymbolicLink()) {
15457
- const rxl = this.parsePathToRXL(relPath);
15458
- if (rxl) {
15459
- locators.push(rxl);
15479
+ const rxi = this.parsePathToRXI(relPath);
15480
+ if (rxi) {
15481
+ identifiers.push(rxi);
15460
15482
  }
15461
15483
  } else if (stats.isDirectory()) {
15462
- await this.scanSymlinks(fullPath, relPath, locators);
15484
+ await this.scanSymlinks(fullPath, relPath, identifiers);
15463
15485
  }
15464
15486
  } catch {}
15465
15487
  }
15466
15488
  }
15467
- parsePathToRXL(relPath) {
15489
+ parsePathToRXI(relPath) {
15468
15490
  const parts = relPath.split("/");
15469
15491
  if (parts.length < 3) {
15470
15492
  return null;
@@ -15842,4 +15864,4 @@ export {
15842
15864
  CASRegistry
15843
15865
  };
15844
15866
 
15845
- //# debugId=7C301A1A890CF92B64756E2164756E21
15867
+ //# debugId=8AF33945E518861764756E2164756E21