@feltdb/core 0.2.0 → 0.3.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/LICENSE +19 -0
- package/dist/analytics-backend.d.ts +39 -0
- package/dist/analytics-backend.d.ts.map +1 -0
- package/dist/analytics-backend.js +152 -0
- package/dist/application-contract.d.ts +49 -0
- package/dist/application-contract.d.ts.map +1 -0
- package/dist/application-contract.js +13 -0
- package/dist/application-manifest.d.ts +305 -0
- package/dist/application-manifest.d.ts.map +1 -0
- package/dist/application-manifest.js +26 -0
- package/dist/artifact.d.ts +73 -0
- package/dist/artifact.d.ts.map +1 -0
- package/dist/artifact.js +21 -0
- package/dist/authorization.d.ts +99 -0
- package/dist/authorization.d.ts.map +1 -0
- package/dist/authorization.js +15 -0
- package/dist/bundle.d.ts +55 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +13 -0
- package/dist/collection.d.ts +28 -0
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +83 -0
- package/dist/db.d.ts +18 -0
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +20 -8
- package/dist/distributed-indexing.d.ts +170 -0
- package/dist/distributed-indexing.d.ts.map +1 -0
- package/dist/distributed-indexing.js +260 -0
- package/dist/flowspec.d.ts +4 -0
- package/dist/flowspec.d.ts.map +1 -1
- package/dist/flowspec.js +8 -0
- package/dist/http-client.d.ts +35 -0
- package/dist/http-client.d.ts.map +1 -0
- package/dist/http-client.js +70 -0
- package/dist/identity.d.ts +40 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +10 -0
- package/dist/index-analytics.d.ts +121 -0
- package/dist/index-analytics.d.ts.map +1 -0
- package/dist/index-analytics.js +279 -0
- package/dist/index-backend.d.ts +26 -0
- package/dist/index-backend.d.ts.map +1 -0
- package/dist/index-backend.js +115 -0
- package/dist/index-dashboard.d.ts +114 -0
- package/dist/index-dashboard.d.ts.map +1 -0
- package/dist/index-dashboard.js +256 -0
- package/dist/index-manager.d.ts +18 -0
- package/dist/index-manager.d.ts.map +1 -0
- package/dist/index-manager.js +333 -0
- package/dist/index-monitoring.d.ts +133 -0
- package/dist/index-monitoring.d.ts.map +1 -0
- package/dist/index-monitoring.js +218 -0
- package/dist/index-recovery.d.ts +57 -0
- package/dist/index-recovery.d.ts.map +1 -0
- package/dist/index-recovery.js +117 -0
- package/dist/index-store.d.ts +62 -0
- package/dist/index-store.d.ts.map +1 -0
- package/dist/index-store.js +141 -0
- package/dist/index-types.d.ts +70 -0
- package/dist/index-types.d.ts.map +1 -0
- package/dist/index-types.js +6 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -0
- package/dist/observe.d.ts +51 -0
- package/dist/observe.d.ts.map +1 -0
- package/dist/observe.js +14 -0
- package/dist/protocol.d.ts +25 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +18 -0
- package/dist/provider.d.ts +61 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +17 -0
- package/dist/query-planner.d.ts +69 -0
- package/dist/query-planner.d.ts.map +1 -0
- package/dist/query-planner.js +184 -0
- package/dist/release.d.ts +60 -0
- package/dist/release.d.ts.map +1 -0
- package/dist/release.js +18 -0
- package/dist/sharding.d.ts +159 -0
- package/dist/sharding.d.ts.map +1 -0
- package/dist/sharding.js +317 -0
- package/dist/state-contract.d.ts +173 -0
- package/dist/state-contract.d.ts.map +1 -0
- package/dist/state-contract.js +24 -0
- package/dist/sync-contract.d.ts +101 -0
- package/dist/sync-contract.d.ts.map +1 -0
- package/dist/sync-contract.js +90 -0
- package/dist/worker.d.ts +90 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +26 -0
- package/dist/workload.d.ts +102 -0
- package/dist/workload.d.ts.map +1 -0
- package/dist/workload.js +23 -0
- package/package.json +17 -5
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export type ArtifactKind = 'SOURCE' | 'DOCUMENT' | 'IMAGE' | 'DATASET' | 'FORM' | 'BUILD' | 'PACKAGE' | 'MODEL_OUTPUT' | 'EXECUTION_OUTPUT' | 'LOG' | 'REPORT' | 'BACKUP' | 'EXPORT' | 'IMPORT' | 'APPLICATION' | 'CONFIGURATION' | {
|
|
2
|
+
OTHER: string;
|
|
3
|
+
};
|
|
4
|
+
export type ArtifactLifecycle = 'CREATED' | 'ACTIVE' | 'SUPERSEDED' | 'ARCHIVED' | 'DELETED';
|
|
5
|
+
export interface Artifact {
|
|
6
|
+
id: string;
|
|
7
|
+
tenant_id: string;
|
|
8
|
+
application_id: string;
|
|
9
|
+
content_hash: string;
|
|
10
|
+
content_type: string;
|
|
11
|
+
size: number;
|
|
12
|
+
kind: ArtifactKind;
|
|
13
|
+
lifecycle: ArtifactLifecycle;
|
|
14
|
+
created_by: string;
|
|
15
|
+
producer: {
|
|
16
|
+
kind: string;
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
source?: string;
|
|
20
|
+
parents: string[];
|
|
21
|
+
supersedes?: string;
|
|
22
|
+
revision?: string;
|
|
23
|
+
workload?: string;
|
|
24
|
+
execution?: string;
|
|
25
|
+
metadata: {
|
|
26
|
+
name: string;
|
|
27
|
+
environment?: string;
|
|
28
|
+
tags: string[];
|
|
29
|
+
labels: Record<string, string>;
|
|
30
|
+
retention: unknown;
|
|
31
|
+
};
|
|
32
|
+
created_at: number;
|
|
33
|
+
}
|
|
34
|
+
export interface CreateArtifact {
|
|
35
|
+
applicationId: string;
|
|
36
|
+
kind: ArtifactKind;
|
|
37
|
+
content: Blob | ArrayBuffer | Uint8Array;
|
|
38
|
+
contentType: string;
|
|
39
|
+
name: string;
|
|
40
|
+
producerKind?: string;
|
|
41
|
+
producerId?: string;
|
|
42
|
+
parents?: string[];
|
|
43
|
+
supersedes?: string;
|
|
44
|
+
revision?: string;
|
|
45
|
+
workload?: string;
|
|
46
|
+
execution?: string;
|
|
47
|
+
}
|
|
48
|
+
export declare class ArtifactClient {
|
|
49
|
+
private baseUrl;
|
|
50
|
+
private fetcher;
|
|
51
|
+
constructor(baseUrl?: string, fetcher?: typeof fetch);
|
|
52
|
+
private json;
|
|
53
|
+
create(input: CreateArtifact): Promise<Artifact>;
|
|
54
|
+
list(applicationId: string): Promise<{
|
|
55
|
+
artifacts: Artifact[];
|
|
56
|
+
}>;
|
|
57
|
+
get(id: string): Promise<Artifact>;
|
|
58
|
+
content(id: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
59
|
+
provenance(id: string): Promise<{
|
|
60
|
+
artifact: Artifact;
|
|
61
|
+
parents: Artifact[];
|
|
62
|
+
children: Artifact[];
|
|
63
|
+
}>;
|
|
64
|
+
parents(id: string): Promise<{
|
|
65
|
+
artifacts: Artifact[];
|
|
66
|
+
}>;
|
|
67
|
+
children(id: string): Promise<{
|
|
68
|
+
artifacts: Artifact[];
|
|
69
|
+
}>;
|
|
70
|
+
archive(id: string): Promise<Artifact>;
|
|
71
|
+
restore(id: string): Promise<Artifact>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=artifact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.d.ts","sourceRoot":"","sources":["../src/artifact.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAC,QAAQ,GAAC,UAAU,GAAC,OAAO,GAAC,SAAS,GAAC,MAAM,GAAC,OAAO,GAAC,SAAS,GAAC,cAAc,GAAC,kBAAkB,GAAC,KAAK,GAAC,QAAQ,GAAC,QAAQ,GAAC,QAAQ,GAAC,QAAQ,GAAC,aAAa,GAAC,eAAe,GAAC;IAAC,KAAK,EAAC,MAAM,CAAA;CAAC,CAAC;AACjN,MAAM,MAAM,iBAAiB,GAAC,SAAS,GAAC,QAAQ,GAAC,YAAY,GAAC,UAAU,GAAC,SAAS,CAAC;AACnF,MAAM,WAAW,QAAQ;IAAE,EAAE,EAAC,MAAM,CAAC;IAAA,SAAS,EAAC,MAAM,CAAC;IA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M,CAAA;CAAC;AAC3Q,qBAAa,cAAc;IACd,OAAO,CAAC,OAAO;IAAI,OAAO,CAAC,OAAO;gBAA1B,OAAO,SAAG,EAAS,OAAO,GAAC,OAAO,KAAW;YACnD,IAAI;IACZ,MAAM,CAAC,KAAK,EAAC,cAAc;IACjC,IAAI,CAAC,aAAa,EAAC,MAAM;mBAA8B,QAAQ,EAAE;;IACjE,GAAG,CAAC,EAAE,EAAC,MAAM;IACP,OAAO,CAAC,EAAE,EAAC,MAAM;IACvB,UAAU,CAAC,EAAE,EAAC,MAAM;kBAA6B,QAAQ;iBAAS,QAAQ,EAAE;kBAAU,QAAQ,EAAE;;IAChG,OAAO,CAAC,EAAE,EAAC,MAAM;mBAA8B,QAAQ,EAAE;;IAAuD,QAAQ,CAAC,EAAE,EAAC,MAAM;mBAA8B,QAAQ,EAAE;;IAC1K,OAAO,CAAC,EAAE,EAAC,MAAM;IAAiG,OAAO,CAAC,EAAE,EAAC,MAAM;CACnI"}
|
package/dist/artifact.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class ArtifactClient {
|
|
2
|
+
constructor(baseUrl = '', fetcher = fetch) {
|
|
3
|
+
this.baseUrl = baseUrl;
|
|
4
|
+
this.fetcher = fetcher;
|
|
5
|
+
}
|
|
6
|
+
async json(path, init) { const response = await this.fetcher(`${this.baseUrl}${path}`, { credentials: 'include', ...init }); const value = await response.json(); if (!response.ok)
|
|
7
|
+
throw new Error(value?.error || `Artifact request failed (${response.status})`); return value; }
|
|
8
|
+
async create(input) { const query = new URLSearchParams({ application_id: input.applicationId, kind: typeof input.kind === 'string' ? input.kind : `OTHER(${input.kind.OTHER})`, name: input.name, content_type: input.contentType, producer_kind: input.producerKind || 'human', producer_id: input.producerId || '' }); for (const parent of input.parents || [])
|
|
9
|
+
query.append('parents', parent); for (const [key, value] of Object.entries({ supersedes: input.supersedes, revision: input.revision, workload: input.workload, execution: input.execution }))
|
|
10
|
+
if (value)
|
|
11
|
+
query.set(key, value); return this.json(`/v1/artifacts?${query}`, { method: 'POST', headers: { 'content-type': input.contentType }, body: input.content instanceof Blob ? input.content : input.content instanceof Uint8Array ? input.content : input.content }); }
|
|
12
|
+
list(applicationId) { return this.json(`/v1/artifacts?application_id=${encodeURIComponent(applicationId)}`); }
|
|
13
|
+
get(id) { return this.json(`/v1/artifacts/${encodeURIComponent(id)}`); }
|
|
14
|
+
async content(id) { const response = await this.fetcher(`${this.baseUrl}/v1/artifacts/${encodeURIComponent(id)}/content`, { credentials: 'include' }); if (!response.ok)
|
|
15
|
+
throw new Error(`Artifact content failed (${response.status})`); return new Uint8Array(await response.arrayBuffer()); }
|
|
16
|
+
provenance(id) { return this.json(`/v1/artifacts/${encodeURIComponent(id)}/provenance`); }
|
|
17
|
+
parents(id) { return this.json(`/v1/artifacts/${encodeURIComponent(id)}/parents`); }
|
|
18
|
+
children(id) { return this.json(`/v1/artifacts/${encodeURIComponent(id)}/children`); }
|
|
19
|
+
archive(id) { return this.json(`/v1/artifacts/${encodeURIComponent(id)}/archive`, { method: 'POST' }); }
|
|
20
|
+
restore(id) { return this.json(`/v1/artifacts/${encodeURIComponent(id)}/restore`, { method: 'POST' }); }
|
|
21
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export type AuthorizationSubject = {
|
|
2
|
+
kind: 'human' | 'service' | 'workload' | 'agent' | 'connection' | 'worker';
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
export type ResourceScopeKind = 'APPLICATION' | 'COLLECTION' | 'RESOURCE' | 'RESOURCE_PREFIX' | 'WORKLOAD' | 'CONNECTION' | 'ARTIFACT';
|
|
6
|
+
export interface AuthorizationResource {
|
|
7
|
+
uri: string;
|
|
8
|
+
attributes?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export interface ResourceScope {
|
|
11
|
+
kind: ResourceScopeKind;
|
|
12
|
+
uri: string;
|
|
13
|
+
}
|
|
14
|
+
export interface GrantConstraints {
|
|
15
|
+
environments?: string[];
|
|
16
|
+
worker_class?: string;
|
|
17
|
+
network?: string;
|
|
18
|
+
workload_id?: string;
|
|
19
|
+
connection_enabled?: boolean;
|
|
20
|
+
minimum_schema_version?: number;
|
|
21
|
+
subject_attributes?: Record<string, string>;
|
|
22
|
+
resource_attributes?: Record<string, string>;
|
|
23
|
+
context_attributes?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
export interface AuthorizationContext {
|
|
26
|
+
environment?: string;
|
|
27
|
+
execution_id?: string;
|
|
28
|
+
workload_id?: string;
|
|
29
|
+
worker_id?: string;
|
|
30
|
+
connection_id?: string;
|
|
31
|
+
timestamp: number;
|
|
32
|
+
attributes?: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
export interface Grant {
|
|
35
|
+
contract_version: 1;
|
|
36
|
+
id: string;
|
|
37
|
+
issuer: AuthorizationSubject;
|
|
38
|
+
subject: AuthorizationSubject;
|
|
39
|
+
tenant_id: string;
|
|
40
|
+
application_id: string;
|
|
41
|
+
capabilities: string[];
|
|
42
|
+
resources: ResourceScope[];
|
|
43
|
+
constraints?: GrantConstraints;
|
|
44
|
+
issued_at: number;
|
|
45
|
+
expires_at: number;
|
|
46
|
+
parent_grant?: string;
|
|
47
|
+
revision: number;
|
|
48
|
+
status: 'ACTIVE' | 'REVOKED' | 'EXPIRED' | 'SUPERSEDED';
|
|
49
|
+
}
|
|
50
|
+
export interface SignedGrant {
|
|
51
|
+
algorithm: 'ED25519-V1';
|
|
52
|
+
key_id: string;
|
|
53
|
+
grant: Grant;
|
|
54
|
+
digest: string;
|
|
55
|
+
signature: string;
|
|
56
|
+
}
|
|
57
|
+
export interface AuthorizationRequest {
|
|
58
|
+
subject: AuthorizationSubject;
|
|
59
|
+
tenant_id: string;
|
|
60
|
+
application_id: string;
|
|
61
|
+
resource: AuthorizationResource;
|
|
62
|
+
capability: string;
|
|
63
|
+
context: AuthorizationContext;
|
|
64
|
+
grant_id?: string;
|
|
65
|
+
subject_attributes?: Record<string, string>;
|
|
66
|
+
}
|
|
67
|
+
export interface AuthorizationDecision {
|
|
68
|
+
decision_id: string;
|
|
69
|
+
request_hash: string;
|
|
70
|
+
decision_hash: string;
|
|
71
|
+
allowed: boolean;
|
|
72
|
+
subject: AuthorizationSubject;
|
|
73
|
+
tenant_id: string;
|
|
74
|
+
application_id: string;
|
|
75
|
+
resource: AuthorizationResource;
|
|
76
|
+
capability: string;
|
|
77
|
+
grant_id?: string;
|
|
78
|
+
policy_version: string;
|
|
79
|
+
evaluated_at: number;
|
|
80
|
+
reason: string;
|
|
81
|
+
}
|
|
82
|
+
export declare class AuthorizationClient {
|
|
83
|
+
private readonly baseUrl;
|
|
84
|
+
private readonly fetcher;
|
|
85
|
+
constructor(baseUrl?: string, fetcher?: typeof fetch);
|
|
86
|
+
private json;
|
|
87
|
+
check(request: AuthorizationRequest): Promise<AuthorizationDecision>;
|
|
88
|
+
verificationKey(): Promise<{
|
|
89
|
+
algorithm: "ED25519-V1";
|
|
90
|
+
key_id: string;
|
|
91
|
+
public_key: string;
|
|
92
|
+
}>;
|
|
93
|
+
create(grant: Grant): Promise<SignedGrant>;
|
|
94
|
+
inspect(id: string): Promise<SignedGrant>;
|
|
95
|
+
revoke(id: string): Promise<SignedGrant>;
|
|
96
|
+
delegate(parentId: string, grant: Grant): Promise<SignedGrant>;
|
|
97
|
+
decision(id: string): Promise<AuthorizationDecision>;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=authorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IAAE,IAAI,EAAE,OAAO,GAAC,SAAS,GAAC,UAAU,GAAC,OAAO,GAAC,YAAY,GAAC,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AACpH,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAC,YAAY,GAAC,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;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AAE7U,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAAK,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAApC,OAAO,SAAG,EAAmB,OAAO,GAAE,OAAO,KAAW;YACvE,IAAI;IAClB,KAAK,CAAC,OAAO,EAAC,oBAAoB;IAClC,eAAe;mBAA+B,YAAY;gBAAQ,MAAM;oBAAY,MAAM;;IAC1F,MAAM,CAAC,KAAK,EAAC,KAAK;IAClB,OAAO,CAAC,EAAE,EAAC,MAAM;IACjB,MAAM,CAAC,EAAE,EAAC,MAAM;IAChB,QAAQ,CAAC,QAAQ,EAAC,MAAM,EAAC,KAAK,EAAC,KAAK;IACpC,QAAQ,CAAC,EAAE,EAAC,MAAM;CACnB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class AuthorizationClient {
|
|
2
|
+
constructor(baseUrl = '', fetcher = fetch) {
|
|
3
|
+
this.baseUrl = baseUrl;
|
|
4
|
+
this.fetcher = fetcher;
|
|
5
|
+
}
|
|
6
|
+
async json(path, init) { const response = await this.fetcher(`${this.baseUrl}${path}`, { credentials: 'include', headers: { 'content-type': 'application/json', ...(init?.headers || {}) }, ...init }); const value = await response.json(); if (!response.ok)
|
|
7
|
+
throw new Error(value.error || `Authorization request failed (${response.status})`); return value; }
|
|
8
|
+
check(request) { return this.json('/v1/authorization/check', { method: 'POST', body: JSON.stringify(request) }); }
|
|
9
|
+
verificationKey() { return this.json('/v1/authorization/key'); }
|
|
10
|
+
create(grant) { return this.json('/v1/grants', { method: 'POST', body: JSON.stringify(grant) }); }
|
|
11
|
+
inspect(id) { return this.json(`/v1/grants/${encodeURIComponent(id)}`); }
|
|
12
|
+
revoke(id) { return this.json(`/v1/grants/${encodeURIComponent(id)}/revoke`, { method: 'POST' }); }
|
|
13
|
+
delegate(parentId, grant) { return this.json(`/v1/grants/${encodeURIComponent(parentId)}/delegate`, { method: 'POST', body: JSON.stringify({ grant }) }); }
|
|
14
|
+
decision(id) { return this.json(`/v1/authorization/decisions/${encodeURIComponent(id)}`); }
|
|
15
|
+
}
|
package/dist/bundle.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface BundleOptions {
|
|
2
|
+
include_data?: boolean;
|
|
3
|
+
include_artifacts?: boolean;
|
|
4
|
+
include_history?: boolean;
|
|
5
|
+
include_audit?: boolean;
|
|
6
|
+
include_provenance?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export type ImportMode = 'new' | 'clone' | 'restore' | 'replace' | 'merge';
|
|
9
|
+
export interface PortableBundle {
|
|
10
|
+
format: 'feltdb-bundle/v1';
|
|
11
|
+
bundle: {
|
|
12
|
+
bundle_id: string;
|
|
13
|
+
format_version: number;
|
|
14
|
+
feltdb_version: string;
|
|
15
|
+
tenant_id: string;
|
|
16
|
+
application_id: string;
|
|
17
|
+
application_revision?: string;
|
|
18
|
+
integrity_root: string;
|
|
19
|
+
options: BundleOptions;
|
|
20
|
+
};
|
|
21
|
+
manifest: unknown;
|
|
22
|
+
revisions: unknown[];
|
|
23
|
+
state?: unknown;
|
|
24
|
+
artifacts: unknown[];
|
|
25
|
+
connections: unknown[];
|
|
26
|
+
checksums: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
export interface ImportPlan {
|
|
29
|
+
bundle_id: string;
|
|
30
|
+
mode: ImportMode;
|
|
31
|
+
destination_tenant: string;
|
|
32
|
+
destination_application?: string;
|
|
33
|
+
creates: Record<string, number>;
|
|
34
|
+
requires_secret_bindings: string[];
|
|
35
|
+
requires_provider_bindings: string[];
|
|
36
|
+
warnings: string[];
|
|
37
|
+
integrity_root: string;
|
|
38
|
+
mutates_destination: false;
|
|
39
|
+
}
|
|
40
|
+
export declare class BundleClient {
|
|
41
|
+
private baseUrl;
|
|
42
|
+
private fetcher;
|
|
43
|
+
constructor(baseUrl?: string, fetcher?: typeof fetch);
|
|
44
|
+
private json;
|
|
45
|
+
export(applicationId: string, options?: BundleOptions): Promise<PortableBundle>;
|
|
46
|
+
inspect(id: string): Promise<PortableBundle>;
|
|
47
|
+
verify(id: string): Promise<{
|
|
48
|
+
valid: true;
|
|
49
|
+
bundle_id: string;
|
|
50
|
+
integrity_root: string;
|
|
51
|
+
}>;
|
|
52
|
+
planImport(bundle: PortableBundle, mode: ImportMode, destinationTenant: string, destinationApplication?: string): Promise<ImportPlan>;
|
|
53
|
+
import(bundle: PortableBundle, mode: ImportMode, destinationTenant: string, destinationApplication: string): Promise<unknown>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAAC,YAAY,CAAC,EAAC,OAAO,CAAC;IAAA,iBAAiB,CAAC,EAAC,OAAO,CAAC;IAAA,eAAe,CAAC,EAAC,OAAO,CAAC;IAAA,aAAa,CAAC,EAAC,OAAO,CAAC;IAAA,kBAAkB,CAAC,EAAC,OAAO,CAAA;CAAC;AAC5J,MAAM,MAAM,UAAU,GAAC,KAAK,GAAC,OAAO,GAAC,SAAS,GAAC,SAAS,GAAC,OAAO,CAAC;AACjE,MAAM,WAAW,cAAc;IAAC,MAAM,EAAC,kBAAkB,CAAC;IAAA,MAAM,EAAC;QAAC,SAAS,EAAC,MAAM,CAAC;QAAA,cAAc,EAAC,MAAM,CAAC;QAAA,cAAc,EAAC,MAAM,CAAC;QAAA,SAAS,EAAC,MAAM,CAAC;QAAA,cAAc,EAAC,MAAM,CAAC;QAAA,oBAAoB,CAAC,EAAC,MAAM,CAAC;QAAA,cAAc,EAAC,MAAM,CAAC;QAAA,OAAO,EAAC,aAAa,CAAA;KAAC,CAAC;IAAA,QAAQ,EAAC,OAAO,CAAC;IAAA,SAAS,EAAC,OAAO,EAAE,CAAC;IAAA,K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
|
3
|
+
this.baseUrl = baseUrl;
|
|
4
|
+
this.fetcher = fetcher;
|
|
5
|
+
}
|
|
6
|
+
async json(path, init) { const response = await this.fetcher(`${this.baseUrl}${path}`, { credentials: 'include', headers: { 'content-type': 'application/json' }, ...init }); const value = await response.json(); if (!response.ok)
|
|
7
|
+
throw new Error(value?.error || `Bundle request failed (${response.status})`); return value; }
|
|
8
|
+
export(applicationId, options = {}) { return this.json('/v1/bundles/export', { method: 'POST', body: JSON.stringify({ application_id: applicationId, options }) }); }
|
|
9
|
+
inspect(id) { return this.json(`/v1/bundles/${encodeURIComponent(id)}`); }
|
|
10
|
+
verify(id) { return this.json(`/v1/bundles/${encodeURIComponent(id)}/verify`, { method: 'POST' }); }
|
|
11
|
+
planImport(bundle, mode, destinationTenant, destinationApplication) { return this.json('/v1/bundles/import/plan', { method: 'POST', body: JSON.stringify({ bundle, mode, destination_tenant: destinationTenant, destination_application: destinationApplication }) }); }
|
|
12
|
+
import(bundle, mode, destinationTenant, destinationApplication) { return this.json('/v1/bundles/import/apply', { method: 'POST', body: JSON.stringify({ bundle, mode, destination_tenant: destinationTenant, destination_application: destinationApplication }) }); }
|
|
13
|
+
}
|
package/dist/collection.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* for efficient, real-time state propagation.
|
|
9
9
|
*/
|
|
10
10
|
import type { JsDb } from './feltdb.js';
|
|
11
|
+
import type { IndexConfig } from './index-types.js';
|
|
11
12
|
export type Predicate<T> = (item: T) => boolean;
|
|
12
13
|
export type Subscriber<T> = (items: T[]) => void;
|
|
13
14
|
/**
|
|
@@ -29,7 +30,14 @@ export declare class Collection<T> {
|
|
|
29
30
|
private unsubscribeFunctions;
|
|
30
31
|
private graphUnsubscribe;
|
|
31
32
|
private runtimeUnsubscribe;
|
|
33
|
+
private indexBackend;
|
|
34
|
+
private indexStore;
|
|
35
|
+
private indexesLoaded;
|
|
32
36
|
constructor(db: JsDb, name: string, predicate?: Predicate<T>, parent?: Collection<T>);
|
|
37
|
+
/**
|
|
38
|
+
* Load indexes that were persisted from a previous session.
|
|
39
|
+
*/
|
|
40
|
+
private loadPersistedIndexes;
|
|
33
41
|
/**
|
|
34
42
|
* Get all records in this collection.
|
|
35
43
|
* Returns cached results (live-updated).
|
|
@@ -37,6 +45,26 @@ export declare class Collection<T> {
|
|
|
37
45
|
all(): Promise<T[]>;
|
|
38
46
|
/** Find records whose fields match the supplied query. */
|
|
39
47
|
find(query?: Partial<T>): Promise<T[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Create an index on this collection for faster queries.
|
|
50
|
+
* @example
|
|
51
|
+
* tasks.createIndex({ name: 'status_idx', type: 'hash', field: 'status' });
|
|
52
|
+
* tasks.createIndex({ name: 'created_idx', type: 'sorted', field: 'createdAt' });
|
|
53
|
+
*/
|
|
54
|
+
createIndex(config: IndexConfig): void;
|
|
55
|
+
/**
|
|
56
|
+
* List all indexes on this collection.
|
|
57
|
+
*/
|
|
58
|
+
listIndexes(): IndexConfig[];
|
|
59
|
+
/**
|
|
60
|
+
* Rebuild all indexes for this collection.
|
|
61
|
+
* Used to repair corrupted indexes or after data migration.
|
|
62
|
+
*/
|
|
63
|
+
rebuildIndexes(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Check if indexes are stale and need rebuilding.
|
|
66
|
+
*/
|
|
67
|
+
validateIndexes(): Promise<boolean>;
|
|
40
68
|
/**
|
|
41
69
|
* Get a single record by ID.
|
|
42
70
|
*/
|
package/dist/collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI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QAAQ,EAAE,IAAI,EACd,OAAO,EAAE,IAAI,EACb,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,MAAM;IAQ/C;;OAEG;IACG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;CAoBxD"}
|
package/dist/collection.js
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* for efficient, real-time state propagation.
|
|
9
9
|
*/
|
|
10
10
|
import { getReactiveDependencyGraph } from './reactive-graph.js';
|
|
11
|
+
import { IndexBackend } from './index-backend.js';
|
|
12
|
+
import { IndexStore } from './index-store.js';
|
|
11
13
|
/**
|
|
12
14
|
* A live collection that automatically updates when underlying data changes.
|
|
13
15
|
* Represents application state, not a one-time query result.
|
|
@@ -25,17 +27,38 @@ export class Collection {
|
|
|
25
27
|
this.unsubscribeFunctions = new Set();
|
|
26
28
|
this.graphUnsubscribe = null;
|
|
27
29
|
this.runtimeUnsubscribe = null;
|
|
30
|
+
this.indexBackend = new IndexBackend();
|
|
31
|
+
this.indexesLoaded = false;
|
|
28
32
|
this.db = db;
|
|
29
33
|
this.name = name;
|
|
30
34
|
this.collectionId = `${name}-${Math.random().toString(36).substr(2, 9)}`;
|
|
31
35
|
this.predicate = predicate || null;
|
|
32
36
|
this.parent = parent || null;
|
|
33
37
|
this.parentId = parent ? parent.collectionId : null;
|
|
38
|
+
this.indexStore = new IndexStore(db, name);
|
|
34
39
|
// Register dependency if this is a derived collection
|
|
35
40
|
if (parent) {
|
|
36
41
|
const graph = getReactiveDependencyGraph();
|
|
37
42
|
graph.registerDependency(parent.collectionId, this.collectionId);
|
|
38
43
|
}
|
|
44
|
+
// Load persisted indexes asynchronously
|
|
45
|
+
this.loadPersistedIndexes();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Load indexes that were persisted from a previous session.
|
|
49
|
+
*/
|
|
50
|
+
async loadPersistedIndexes() {
|
|
51
|
+
try {
|
|
52
|
+
const configs = await this.indexStore.loadIndexConfigs();
|
|
53
|
+
for (const config of configs) {
|
|
54
|
+
this.indexBackend.createIndex(config);
|
|
55
|
+
}
|
|
56
|
+
this.indexesLoaded = true;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.warn(`Failed to load persisted indexes for ${this.name}:`, error);
|
|
60
|
+
this.indexesLoaded = true;
|
|
61
|
+
}
|
|
39
62
|
}
|
|
40
63
|
/**
|
|
41
64
|
* Get all records in this collection.
|
|
@@ -51,6 +74,57 @@ export class Collection {
|
|
|
51
74
|
const entries = Object.entries(query);
|
|
52
75
|
return items.filter((item) => entries.every(([field, expected]) => item[field] === expected));
|
|
53
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Create an index on this collection for faster queries.
|
|
79
|
+
* @example
|
|
80
|
+
* tasks.createIndex({ name: 'status_idx', type: 'hash', field: 'status' });
|
|
81
|
+
* tasks.createIndex({ name: 'created_idx', type: 'sorted', field: 'createdAt' });
|
|
82
|
+
*/
|
|
83
|
+
createIndex(config) {
|
|
84
|
+
this.indexBackend.createIndex(config);
|
|
85
|
+
// Index existing data
|
|
86
|
+
for (const item of this.cache) {
|
|
87
|
+
const recordId = item?.id || JSON.stringify(item);
|
|
88
|
+
this.indexBackend.updateRecord(recordId, null, item);
|
|
89
|
+
}
|
|
90
|
+
// Persist index configuration
|
|
91
|
+
void this.indexStore.saveIndexConfig(config, this.cache.length);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* List all indexes on this collection.
|
|
95
|
+
*/
|
|
96
|
+
listIndexes() {
|
|
97
|
+
return this.indexBackend.listIndexes();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Rebuild all indexes for this collection.
|
|
101
|
+
* Used to repair corrupted indexes or after data migration.
|
|
102
|
+
*/
|
|
103
|
+
async rebuildIndexes() {
|
|
104
|
+
const configs = this.indexBackend.listIndexes();
|
|
105
|
+
const items = await this.all();
|
|
106
|
+
for (const item of items) {
|
|
107
|
+
const recordId = item?.id || JSON.stringify(item);
|
|
108
|
+
for (const config of configs) {
|
|
109
|
+
this.indexBackend.updateRecord(recordId, null, item);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Check if indexes are stale and need rebuilding.
|
|
115
|
+
*/
|
|
116
|
+
async validateIndexes() {
|
|
117
|
+
const configs = this.indexBackend.listIndexes();
|
|
118
|
+
if (configs.length === 0)
|
|
119
|
+
return true;
|
|
120
|
+
const items = await this.all();
|
|
121
|
+
// If we have indexes but no items, they're valid
|
|
122
|
+
if (items.length === 0)
|
|
123
|
+
return true;
|
|
124
|
+
// For now, just return true - actual validation would check entry counts
|
|
125
|
+
// from IndexStats which we'll track in the backend
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
54
128
|
/**
|
|
55
129
|
* Get a single record by ID.
|
|
56
130
|
*/
|
|
@@ -90,6 +164,8 @@ export class Collection {
|
|
|
90
164
|
if (!result.success) {
|
|
91
165
|
throw new Error(`Insert failed: ${result.error}`);
|
|
92
166
|
}
|
|
167
|
+
// Update indexes
|
|
168
|
+
this.indexBackend.updateRecord(String(recordId), null, stored);
|
|
93
169
|
// Emit change through reactive dependency graph
|
|
94
170
|
const change = {
|
|
95
171
|
type: 'insert',
|
|
@@ -117,6 +193,8 @@ export class Collection {
|
|
|
117
193
|
if (!result.success) {
|
|
118
194
|
throw new Error(`Update failed: ${result.error}`);
|
|
119
195
|
}
|
|
196
|
+
// Update indexes
|
|
197
|
+
this.indexBackend.updateRecord(String(id), current, updated);
|
|
120
198
|
// Emit change through reactive dependency graph
|
|
121
199
|
const change = {
|
|
122
200
|
type: 'update',
|
|
@@ -139,6 +217,11 @@ export class Collection {
|
|
|
139
217
|
if (!result.success) {
|
|
140
218
|
throw new Error(`Delete failed: ${result.error}`);
|
|
141
219
|
}
|
|
220
|
+
// Update indexes - find and remove the deleted record
|
|
221
|
+
const deleted = await this.get(id);
|
|
222
|
+
if (deleted) {
|
|
223
|
+
this.indexBackend.updateRecord(String(id), deleted, {});
|
|
224
|
+
}
|
|
142
225
|
// Emit delete change through reactive dependency graph
|
|
143
226
|
const change = {
|
|
144
227
|
type: 'delete',
|
package/dist/db.d.ts
CHANGED
|
@@ -10,6 +10,14 @@ import type { AgentRef, AgentDefinition, AgentExecution } from './agent.js';
|
|
|
10
10
|
import { AgentRegistry } from './agent-registry.js';
|
|
11
11
|
import { AgentRuntime } from './agent-runtime.js';
|
|
12
12
|
import type { FlowSpec } from './flowspec.js';
|
|
13
|
+
import { SyncController, type SyncConfig } from './sync-contract.js';
|
|
14
|
+
import { WorkloadClient } from './workload.js';
|
|
15
|
+
import { MeshClient, WorkerClient, WorkerPoolClient } from './worker.js';
|
|
16
|
+
import { ArtifactClient } from './artifact.js';
|
|
17
|
+
import { BundleClient } from './bundle.js';
|
|
18
|
+
import { ReleaseClient } from './release.js';
|
|
19
|
+
import { ObserveClient } from './observe.js';
|
|
20
|
+
import { ProviderClient } from './provider.js';
|
|
13
21
|
interface FeltDBBaseOptions {
|
|
14
22
|
namespace: string;
|
|
15
23
|
}
|
|
@@ -224,6 +232,15 @@ export declare class StateFirstDB {
|
|
|
224
232
|
private agentRegistry;
|
|
225
233
|
private agentRuntime;
|
|
226
234
|
private capabilityWorkers;
|
|
235
|
+
readonly workloads: WorkloadClient;
|
|
236
|
+
readonly artifacts: ArtifactClient;
|
|
237
|
+
readonly bundle: BundleClient;
|
|
238
|
+
readonly releases: ReleaseClient;
|
|
239
|
+
readonly observe: ObserveClient;
|
|
240
|
+
readonly providers: ProviderClient;
|
|
241
|
+
readonly workers: WorkerClient;
|
|
242
|
+
readonly workerPools: WorkerPoolClient;
|
|
243
|
+
readonly mesh: MeshClient;
|
|
227
244
|
constructor(jsDb: JsDb);
|
|
228
245
|
/**
|
|
229
246
|
* Detect runtime environment and storage characteristics
|
|
@@ -362,6 +379,7 @@ export declare class StateFirstDB {
|
|
|
362
379
|
* console.log(`Connected to ${syncState.connected_peers.length} peers`);
|
|
363
380
|
*/
|
|
364
381
|
sync(): SyncInfo;
|
|
382
|
+
sync(config: SyncConfig): SyncController;
|
|
365
383
|
/**
|
|
366
384
|
* Add a peer for synchronization.
|
|
367
385
|
*
|
package/dist/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAA2B,MAAM,oBAAoB,CAAC;AAI3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAA2B,MAAM,oBAAoB,CAAC;AAI3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM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C,CAO7B"}
|
package/dist/db.js
CHANGED
|
@@ -12,6 +12,14 @@ import { MemoryJsDb } from './memory-db.js';
|
|
|
12
12
|
import { HttpJsDb } from './http-db.js';
|
|
13
13
|
import { IndexedDbJsDb } from './indexeddb-db.js';
|
|
14
14
|
import { emptyFlowSpec, planFlowSpecMigration, validateFlowSpec } from './flowspec.js';
|
|
15
|
+
import { SyncController } from './sync-contract.js';
|
|
16
|
+
import { WorkloadClient } from './workload.js';
|
|
17
|
+
import { MeshClient, WorkerClient, WorkerPoolClient } from './worker.js';
|
|
18
|
+
import { ArtifactClient } from './artifact.js';
|
|
19
|
+
import { BundleClient } from './bundle.js';
|
|
20
|
+
import { ReleaseClient } from './release.js';
|
|
21
|
+
import { ObserveClient } from './observe.js';
|
|
22
|
+
import { ProviderClient } from './provider.js';
|
|
15
23
|
export function createFeltDB(options) {
|
|
16
24
|
if (!options?.namespace?.trim()) {
|
|
17
25
|
throw new Error('createFeltDB requires a non-empty namespace');
|
|
@@ -29,6 +37,15 @@ export class StateFirstDB {
|
|
|
29
37
|
constructor(jsDb) {
|
|
30
38
|
this.collections = new Map();
|
|
31
39
|
this.capabilityWorkers = new Map();
|
|
40
|
+
this.workloads = new WorkloadClient();
|
|
41
|
+
this.artifacts = new ArtifactClient();
|
|
42
|
+
this.bundle = new BundleClient();
|
|
43
|
+
this.releases = new ReleaseClient();
|
|
44
|
+
this.observe = new ObserveClient();
|
|
45
|
+
this.providers = new ProviderClient();
|
|
46
|
+
this.workers = new WorkerClient();
|
|
47
|
+
this.workerPools = new WorkerPoolClient();
|
|
48
|
+
this.mesh = new MeshClient();
|
|
32
49
|
this.jsDb = jsDb;
|
|
33
50
|
this.runtimeInfo = this.detectRuntime();
|
|
34
51
|
this.agentRegistry = new AgentRegistry();
|
|
@@ -411,14 +428,9 @@ export class StateFirstDB {
|
|
|
411
428
|
this.collections.clear();
|
|
412
429
|
await this.jsDb.close?.();
|
|
413
430
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
* @example
|
|
418
|
-
* const syncState = db.sync();
|
|
419
|
-
* console.log(`Connected to ${syncState.connected_peers.length} peers`);
|
|
420
|
-
*/
|
|
421
|
-
sync() {
|
|
431
|
+
sync(config) {
|
|
432
|
+
if (config)
|
|
433
|
+
return new SyncController(config);
|
|
422
434
|
const result = this.jsDb.sync_info();
|
|
423
435
|
if (!result.success || !result.data) {
|
|
424
436
|
throw new Error(result.error || 'Failed to get sync info');
|