@skenora/resources 0.1.2
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/README.md +60 -0
- package/dist/http.d.ts +2 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +2 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/memory.d.ts +2 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +2 -0
- package/dist/memory.js.map +1 -0
- package/dist/providers/http-provider.d.ts +22 -0
- package/dist/providers/http-provider.d.ts.map +1 -0
- package/dist/providers/http-provider.js +157 -0
- package/dist/providers/http-provider.js.map +1 -0
- package/dist/providers/memory-provider.d.ts +19 -0
- package/dist/providers/memory-provider.d.ts.map +1 -0
- package/dist/providers/memory-provider.js +131 -0
- package/dist/providers/memory-provider.js.map +1 -0
- package/dist/providers/workspace-provider.d.ts +14 -0
- package/dist/providers/workspace-provider.d.ts.map +1 -0
- package/dist/providers/workspace-provider.js +126 -0
- package/dist/providers/workspace-provider.js.map +1 -0
- package/dist/resource-bindings.d.ts +94 -0
- package/dist/resource-bindings.d.ts.map +1 -0
- package/dist/resource-bindings.js +546 -0
- package/dist/resource-bindings.js.map +1 -0
- package/dist/resource-manager.d.ts +29 -0
- package/dist/resource-manager.d.ts.map +1 -0
- package/dist/resource-manager.js +380 -0
- package/dist/resource-manager.js.map +1 -0
- package/dist/types.d.ts +144 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +30 -0
- package/dist/types.js.map +1 -0
- package/dist/workspace-resource-context.d.ts +21 -0
- package/dist/workspace-resource-context.d.ts.map +1 -0
- package/dist/workspace-resource-context.js +22 -0
- package/dist/workspace-resource-context.js.map +1 -0
- package/dist/workspace.d.ts +3 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +3 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +47 -0
package/dist/types.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function assetReferenceFromDescriptor(descriptor, assetId) {
|
|
2
|
+
const id = assetId.trim();
|
|
3
|
+
if (!id || id !== assetId) {
|
|
4
|
+
throw new Error("Scene asset id must be a normalized non-empty string");
|
|
5
|
+
}
|
|
6
|
+
return {
|
|
7
|
+
id,
|
|
8
|
+
kind: descriptor.kind,
|
|
9
|
+
label: descriptor.label,
|
|
10
|
+
source: structuredClone(descriptor.source),
|
|
11
|
+
...(descriptor.mediaType ? { mediaType: descriptor.mediaType } : {}),
|
|
12
|
+
...(descriptor.integrity
|
|
13
|
+
? { integrity: structuredClone(descriptor.integrity) }
|
|
14
|
+
: {}),
|
|
15
|
+
provenance: {
|
|
16
|
+
originalResourceId: descriptor.id,
|
|
17
|
+
...(descriptor.license?.id ? { license: descriptor.license.id } : {}),
|
|
18
|
+
...(descriptor.license?.attribution
|
|
19
|
+
? { attribution: descriptor.license.attribution }
|
|
20
|
+
: {}),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function supportsResourceDiscovery(value) {
|
|
25
|
+
const candidate = value;
|
|
26
|
+
return (typeof candidate.search === "function" &&
|
|
27
|
+
typeof candidate.describe === "function" &&
|
|
28
|
+
typeof candidate.preflight === "function");
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAoLA,MAAM,UAAU,4BAA4B,CAC1C,UAAwC,EACxC,OAAe;IAEf,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO;QACL,EAAE;QACF,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,MAAM,EAAE,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC;QAC1C,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,GAAG,CAAC,UAAU,CAAC,SAAS;YACtB,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YACtD,CAAC,CAAC,EAAE,CAAC;QACP,UAAU,EAAE;YACV,kBAAkB,EAAE,UAAU,CAAC,EAAE;YACjC,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW;gBACjC,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE;gBACjD,CAAC,CAAC,EAAE,CAAC;SACR;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,KAAuB;IAEvB,MAAM,SAAS,GAAG,KAAmC,CAAC;IACtD,OAAO,CACL,OAAO,SAAS,CAAC,MAAM,KAAK,UAAU;QACtC,OAAO,SAAS,CAAC,QAAQ,KAAK,UAAU;QACxC,OAAO,SAAS,CAAC,SAAS,KAAK,UAAU,CAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { WorkspaceSource } from "@skenora/workspace";
|
|
2
|
+
import { ResourceManager } from "./resource-manager.js";
|
|
3
|
+
import type { ResourceProvider, ResourceResolver } from "./types.js";
|
|
4
|
+
export interface WorkspaceResourceContextOptions {
|
|
5
|
+
/** Host-owned resolver. Mutually exclusive with resourceProviders. */
|
|
6
|
+
resources?: ResourceResolver;
|
|
7
|
+
/** Providers installed after the default workspace provider. */
|
|
8
|
+
resourceProviders?: readonly ResourceProvider[];
|
|
9
|
+
}
|
|
10
|
+
export interface WorkspaceResourceContext {
|
|
11
|
+
/** Resolver passed into runtime document loading. */
|
|
12
|
+
resources: ResourceResolver;
|
|
13
|
+
/** Local manager owned by the caller, or null for a host-owned resolver. */
|
|
14
|
+
ownedResources: ResourceManager | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates the standard local-first resource composition shared by products.
|
|
18
|
+
* The caller remains responsible for disposing ownedResources.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createWorkspaceResourceContext(source: WorkspaceSource, options?: WorkspaceResourceContextOptions): WorkspaceResourceContext;
|
|
21
|
+
//# sourceMappingURL=workspace-resource-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-resource-context.d.ts","sourceRoot":"","sources":["../src/workspace-resource-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAElE,MAAM,WAAW,+BAA+B;IAC9C,sEAAsE;IACtE,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACjD;AAED,MAAM,WAAW,wBAAwB;IACvC,qDAAqD;IACrD,SAAS,EAAE,gBAAgB,CAAC;IAC5B,4EAA4E;IAC5E,cAAc,EAAE,eAAe,GAAG,IAAI,CAAC;CACxC;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,eAAe,EACvB,OAAO,GAAE,+BAAoC,GAC5C,wBAAwB,CAc1B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { WorkspaceResourceProvider } from "./providers/workspace-provider.js";
|
|
2
|
+
import { ResourceManager } from "./resource-manager.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates the standard local-first resource composition shared by products.
|
|
5
|
+
* The caller remains responsible for disposing ownedResources.
|
|
6
|
+
*/
|
|
7
|
+
export function createWorkspaceResourceContext(source, options = {}) {
|
|
8
|
+
if (options.resources && options.resourceProviders?.length) {
|
|
9
|
+
throw new Error("resources and resourceProviders are mutually exclusive");
|
|
10
|
+
}
|
|
11
|
+
if (options.resources) {
|
|
12
|
+
return { resources: options.resources, ownedResources: null };
|
|
13
|
+
}
|
|
14
|
+
const ownedResources = new ResourceManager({
|
|
15
|
+
providers: [
|
|
16
|
+
new WorkspaceResourceProvider(source),
|
|
17
|
+
...(options.resourceProviders ?? []),
|
|
18
|
+
],
|
|
19
|
+
});
|
|
20
|
+
return { resources: ownedResources, ownedResources };
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=workspace-resource-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-resource-context.js","sourceRoot":"","sources":["../src/workspace-resource-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAiBrD;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAC5C,MAAuB,EACvB,UAA2C,EAAE;IAE7C,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;IAChE,CAAC;IACD,MAAM,cAAc,GAAG,IAAI,eAAe,CAAC;QACzC,SAAS,EAAE;YACT,IAAI,yBAAyB,CAAC,MAAM,CAAC;YACrC,GAAG,CAAC,OAAO,CAAC,iBAAiB,IAAI,EAAE,CAAC;SACrC;KACF,CAAC,CAAC;IACH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skenora/resources",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Provider-based resource discovery, policy, caching, and lifecycle management for Skenora.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./workspace": {
|
|
18
|
+
"types": "./dist/workspace.d.ts",
|
|
19
|
+
"import": "./dist/workspace.js",
|
|
20
|
+
"default": "./dist/workspace.js"
|
|
21
|
+
},
|
|
22
|
+
"./http": {
|
|
23
|
+
"types": "./dist/http.d.ts",
|
|
24
|
+
"import": "./dist/http.js",
|
|
25
|
+
"default": "./dist/http.js"
|
|
26
|
+
},
|
|
27
|
+
"./memory": {
|
|
28
|
+
"types": "./dist/memory.d.ts",
|
|
29
|
+
"import": "./dist/memory.js",
|
|
30
|
+
"default": "./dist/memory.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@skenora/contracts": "0.1.2",
|
|
38
|
+
"@skenora/events": "0.1.2",
|
|
39
|
+
"@skenora/workspace": "0.1.2"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc -p tsconfig.json && node ../../scripts/prepare-package-output.mjs dist",
|
|
43
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
44
|
+
},
|
|
45
|
+
"main": "./dist/index.js",
|
|
46
|
+
"types": "./dist/index.d.ts"
|
|
47
|
+
}
|