@selvajs/platform 0.12.0 → 0.12.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selvajs/platform",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Pure TypeScript interfaces for Selva platform providers (auth, definitions, compute)",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -107,7 +107,7 @@
107
107
  ],
108
108
  "dependencies": {
109
109
  "zod": "^4.3.6",
110
- "@selvajs/schemas": "4.0.0"
110
+ "@selvajs/schemas": "4.3.0"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "sharp": "^0.34.0",
package/dist/auth.d.ts DELETED
@@ -1,60 +0,0 @@
1
- /**
2
- * Authentication provider interface.
3
- *
4
- * Implement this to plug in any auth backend:
5
- * - Local HMAC sessions (built-in default)
6
- * - Firebase Auth
7
- * - Supabase Auth
8
- * - AWS Cognito
9
- * - Any OIDC/JWT provider
10
- */
11
- export type UserRole = 'platform_admin' | 'user';
12
- export interface AuthUser {
13
- id: string;
14
- email?: string;
15
- displayName?: string;
16
- role: UserRole;
17
- metadata?: Record<string, unknown>;
18
- }
19
- export interface IAuthProvider {
20
- /**
21
- * Verify a token string — session cookie value, JWT, Firebase ID token, etc.
22
- * Returns the authenticated user, or null if the token is invalid or expired.
23
- */
24
- verifyToken(token: string): Promise<AuthUser | null>;
25
- /**
26
- * Look up a user by their provider-specific ID.
27
- * Returns null if the user does not exist.
28
- */
29
- getUser(id: string): Promise<AuthUser | null>;
30
- /**
31
- * Create a new opaque session token for an authenticated user.
32
- * Stored in a cookie by the transport layer. Format is provider-specific:
33
- * HMAC string, signed JWT, Firebase custom token, etc.
34
- */
35
- createSessionToken(user: AuthUser): Promise<string>;
36
- /**
37
- * Verify login credentials (email + password).
38
- * Returns the authenticated user, or null if credentials are invalid.
39
- * Email may be an empty string for password-only auth (no users.json configured).
40
- */
41
- verifyLoginCredentials(email: string, password: string): Promise<AuthUser | null>;
42
- /**
43
- * List all users. Returns null if this provider does not support user management
44
- * (e.g. single-password mode).
45
- */
46
- listUsers(): Promise<AuthUser[] | null>;
47
- /**
48
- * Create a new user. Returns null if not supported.
49
- */
50
- createUser(email: string, password: string, role: UserRole): Promise<AuthUser | null>;
51
- /**
52
- * Update a user's role. Returns false if not supported or user not found.
53
- */
54
- updateUserRole(id: string, role: UserRole): Promise<boolean>;
55
- /**
56
- * Delete a user by ID. Returns false if not supported or user not found.
57
- */
58
- deleteUser(id: string): Promise<boolean>;
59
- }
60
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,QAAQ,GAAG,gBAAgB,GAAG,MAAM,CAAC;AAEjD,MAAM,WAAW,QAAQ;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,aAAa;IAC7B;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAErD;;;OAGG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAE9C;;;;OAIG;IACH,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpD;;;;OAIG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAIlF;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;IAExC;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAEtF;;OAEG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE7D;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzC"}
package/dist/auth.js DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Authentication provider interface.
3
- *
4
- * Implement this to plug in any auth backend:
5
- * - Local HMAC sessions (built-in default)
6
- * - Firebase Auth
7
- * - Supabase Auth
8
- * - AWS Cognito
9
- * - Any OIDC/JWT provider
10
- */
11
- export {};
12
- //# sourceMappingURL=auth.js.map
package/dist/auth.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
package/dist/compute.d.ts DELETED
@@ -1,47 +0,0 @@
1
- /**
2
- * Compute server provider interface.
3
- *
4
- * Implement to support:
5
- * - Single server (built-in default)
6
- * - Server pool with load balancing
7
- * - Per-definition routing (e.g. definition A always goes to server B)
8
- * - Dynamic provisioning
9
- */
10
- export interface ComputeServerConfig {
11
- /** UUID v4 primary key */
12
- id: string;
13
- /** Human-readable display label */
14
- label: string;
15
- /** Base URL of the Rhino.Compute instance, e.g. http://localhost:5000 */
16
- serverUrl: string;
17
- /** Optional API key sent as RhinoComputeKey header */
18
- apiKey?: string;
19
- /** Request timeout in milliseconds. Default: 30000 */
20
- timeoutMs?: number;
21
- /** Number of retries on transient failure. Default: 0 */
22
- retryCount?: number;
23
- }
24
- export interface ComputeConfig {
25
- servers: ComputeServerConfig[];
26
- /** UUID of the server to use when no routing rule matches. Falls back to servers[0]. */
27
- defaultServerId?: string;
28
- }
29
- export interface SolveRequest {
30
- /** GUID of the definition being solved — enables per-definition routing */
31
- definitionGuid?: string;
32
- /** Arbitrary hints for routing decisions (e.g. required plugin versions) */
33
- hints?: Record<string, string>;
34
- }
35
- export interface IComputeServerProvider {
36
- /** Resolve which compute server to use for a given solve request. */
37
- getServer(request?: SolveRequest): Promise<ComputeServerConfig>;
38
- /** Return the default server, or undefined if none configured. */
39
- getDefaultServer(): Promise<ComputeServerConfig | undefined>;
40
- /** Look up a specific server by its UUID. Returns undefined if not found. */
41
- getServerById(id: string): Promise<ComputeServerConfig | undefined>;
42
- /** Return the full config. Used by the admin UI. */
43
- getConfig(): Promise<ComputeConfig>;
44
- /** Replace the full config atomically. Used by the admin UI. */
45
- saveConfig(config: ComputeConfig): Promise<void>;
46
- }
47
- //# sourceMappingURL=compute.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../src/compute.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,mBAAmB;IACnC,0BAA0B;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,wFAAwF;IACxF,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC5B,2EAA2E;IAC3E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,sBAAsB;IACtC,qEAAqE;IACrE,SAAS,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEhE,kEAAkE;IAClE,gBAAgB,IAAI,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;IAE7D,6EAA6E;IAC7E,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;IAEpE,oDAAoD;IACpD,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAEpC,gEAAgE;IAChE,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD"}
package/dist/compute.js DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * Compute server provider interface.
3
- *
4
- * Implement to support:
5
- * - Single server (built-in default)
6
- * - Server pool with load balancing
7
- * - Per-definition routing (e.g. definition A always goes to server B)
8
- * - Dynamic provisioning
9
- */
10
- export {};
11
- //# sourceMappingURL=compute.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compute.js","sourceRoot":"","sources":["../src/compute.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -1,62 +0,0 @@
1
- import type { IDataProvider } from '../data/interface.js';
2
- import type { IStorageProvider } from '../storage/interface.js';
3
- import type { RequestContext } from '../context.js';
4
- import type { DefinitionRecord, DefinitionFileExt, DefinitionMeta } from './types.js';
5
- import type { UpdateMetadataInput } from './schemas.js';
6
- export interface CreateDefinitionInput {
7
- guid: string;
8
- projectId: string;
9
- ownerId: string;
10
- fileExt: DefinitionFileExt;
11
- meta: DefinitionMeta;
12
- computeServerId?: string;
13
- maxHistory?: number;
14
- }
15
- /**
16
- * Default age threshold after which a 'pending' record is considered stale.
17
- * Conservative — covers slow uploads over weak connections.
18
- */
19
- export declare const PENDING_GC_AGE_MS: number;
20
- /**
21
- * Orchestrates writes that span IDataProvider + IStorageProvider.
22
- *
23
- * Ordering rules (see Phase 4 of the provider refactor):
24
- *
25
- * create — metadata-first:
26
- * 1. Write record with status='pending'
27
- * 2. Upload blob
28
- * 3. Flip status to 'ready'
29
- * If step 2 fails the record stays 'pending' with no blob. List queries
30
- * filter 'pending' by default, so no consumer sees the half-written state.
31
- * The janitor (gcStalePending) sweeps records older than PENDING_GC_AGE_MS.
32
- *
33
- * updateFile — best-effort with retry-safe shape:
34
- * 1. Archive current file to history blob
35
- * 2. Append history entry to record
36
- * 3. Write new file to the active blob path
37
- * 4. Prune history beyond maxHistory
38
- * A failure between 2 and 3 leaves the record pointing at a missing active
39
- * blob. The operation is idempotent — retrying with the same file restores
40
- * a consistent state. This is an acknowledged limitation; the create path
41
- * is where orphan risk is highest and is the one we fully guard.
42
- */
43
- export declare class DefinitionService {
44
- private data;
45
- private storage;
46
- constructor(data: IDataProvider, storage: IStorageProvider);
47
- create(ctx: RequestContext, input: CreateDefinitionInput, file: Uint8Array): Promise<DefinitionRecord>;
48
- updateFile(ctx: RequestContext, guid: string, file: Uint8Array, ext: DefinitionFileExt, originalName: string): Promise<void>;
49
- updateMeta(ctx: RequestContext, guid: string, patch: UpdateMetadataInput): Promise<void>;
50
- saveCoverImage(ctx: RequestContext, guid: string, imageData: Uint8Array): Promise<void>;
51
- revertToVersion(ctx: RequestContext, guid: string, ref: string): Promise<void>;
52
- delete(ctx: RequestContext, guid: string): Promise<void>;
53
- /**
54
- * Janitor — delete records stuck in 'pending' for longer than ageMs and
55
- * any blobs they may have written. Safe to run on a schedule.
56
- * Runs under SYSTEM_CONTEXT; callers don't pass one.
57
- *
58
- * @returns Number of records reclaimed.
59
- */
60
- gcStalePending(ageMs?: number): Promise<number>;
61
- }
62
- //# sourceMappingURL=service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service.d.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;IAYxF,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAOvF,eAAe,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAc9E,MAAM,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9D;;;;;;OAMG;IACG,cAAc,CAAC,KAAK,GAAE,MAA0B,GAAG,OAAO,CAAC,MAAM,CAAC;CASxE"}
@@ -1,149 +0,0 @@
1
- import { SYSTEM_CONTEXT } from '../context.js';
2
- import { ProviderError } from '../errors.js';
3
- import { definitionPaths } from './paths.js';
4
- /**
5
- * Default age threshold after which a 'pending' record is considered stale.
6
- * Conservative — covers slow uploads over weak connections.
7
- */
8
- export const PENDING_GC_AGE_MS = 30 * 60 * 1000; // 30 minutes
9
- /**
10
- * Orchestrates writes that span IDataProvider + IStorageProvider.
11
- *
12
- * Ordering rules (see Phase 4 of the provider refactor):
13
- *
14
- * create — metadata-first:
15
- * 1. Write record with status='pending'
16
- * 2. Upload blob
17
- * 3. Flip status to 'ready'
18
- * If step 2 fails the record stays 'pending' with no blob. List queries
19
- * filter 'pending' by default, so no consumer sees the half-written state.
20
- * The janitor (gcStalePending) sweeps records older than PENDING_GC_AGE_MS.
21
- *
22
- * updateFile — best-effort with retry-safe shape:
23
- * 1. Archive current file to history blob
24
- * 2. Append history entry to record
25
- * 3. Write new file to the active blob path
26
- * 4. Prune history beyond maxHistory
27
- * A failure between 2 and 3 leaves the record pointing at a missing active
28
- * blob. The operation is idempotent — retrying with the same file restores
29
- * a consistent state. This is an acknowledged limitation; the create path
30
- * is where orphan risk is highest and is the one we fully guard.
31
- */
32
- export class DefinitionService {
33
- data;
34
- storage;
35
- constructor(data, storage) {
36
- this.data = data;
37
- this.storage = storage;
38
- }
39
- async create(ctx, input, file) {
40
- const now = new Date().toISOString();
41
- const record = {
42
- guid: input.guid,
43
- projectId: input.projectId,
44
- ownerId: input.ownerId,
45
- fileExt: input.fileExt,
46
- meta: input.meta,
47
- computeServerId: input.computeServerId,
48
- history: [],
49
- maxHistory: input.maxHistory ?? 10,
50
- status: 'pending',
51
- runCount: 0,
52
- createdAt: now,
53
- updatedAt: now
54
- };
55
- // 1. Metadata first — if this fails there's nothing to clean up.
56
- await this.data.definitions.create(ctx, record);
57
- // 2. Blob upload — if this fails the record stays 'pending' for the janitor.
58
- await this.storage.put(definitionPaths.file(input.guid, input.fileExt), file, 'application/octet-stream');
59
- // 3. Flip to draft — the record is now visible to editors.
60
- await this.data.definitions.update(ctx, input.guid, { status: 'draft' });
61
- return { ...record, status: 'draft' };
62
- }
63
- async updateFile(ctx, guid, file, ext, originalName) {
64
- const existing = await this.data.definitions.get(ctx, guid);
65
- if (!existing)
66
- throw new ProviderError(`Definition not found: ${guid}`, 404);
67
- const now = new Date().toISOString();
68
- // UUID-based ref avoids collisions from identical timestamps or special chars in filenames.
69
- const ref = `${crypto.randomUUID()}_${originalName.replace(/[^a-zA-Z0-9._-]/g, '_')}`;
70
- // Archive the current file before overwriting
71
- const currentFile = await this.storage.get(definitionPaths.file(guid, existing.fileExt));
72
- if (currentFile) {
73
- await this.storage.put(definitionPaths.archive(guid, ref), currentFile, 'application/octet-stream');
74
- await this.data.definitions.addHistoryEntry(ctx, guid, {
75
- ref,
76
- originalName,
77
- archivedAt: now
78
- });
79
- }
80
- await this.storage.put(definitionPaths.file(guid, ext), file, 'application/octet-stream');
81
- if (ext !== existing.fileExt) {
82
- await this.storage.delete(definitionPaths.file(guid, existing.fileExt));
83
- }
84
- await this.data.definitions.update(ctx, guid, { fileExt: ext });
85
- // Prune history if maxHistory is set
86
- const updated = await this.data.definitions.get(ctx, guid);
87
- if (updated && updated.maxHistory > 0 && updated.history.length > updated.maxHistory) {
88
- const toRemove = updated.history.slice(updated.maxHistory);
89
- for (const entry of toRemove) {
90
- await this.storage.delete(definitionPaths.archive(guid, entry.ref));
91
- await this.data.definitions.removeHistoryEntry(ctx, guid, entry.ref);
92
- }
93
- }
94
- }
95
- async updateMeta(ctx, guid, patch) {
96
- const { maxHistory, projectId, computeServerId, ...metaFields } = patch;
97
- const meta = Object.keys(metaFields).length > 0 ? metaFields : undefined;
98
- const recordPatch = {
99
- ...(meta !== undefined && { meta }),
100
- ...(maxHistory !== undefined && { maxHistory }),
101
- ...(projectId !== undefined && { projectId }),
102
- ...(computeServerId !== undefined && { computeServerId })
103
- };
104
- await this.data.definitions.update(ctx, guid, recordPatch);
105
- }
106
- async saveCoverImage(ctx, guid, imageData) {
107
- const path = definitionPaths.image(guid);
108
- await this.storage.put(path, imageData, 'image/webp');
109
- const url = this.storage.getPublicUrl(path);
110
- await this.data.definitions.update(ctx, guid, { meta: { coverImage: url } });
111
- }
112
- async revertToVersion(ctx, guid, ref) {
113
- const existing = await this.data.definitions.get(ctx, guid);
114
- if (!existing)
115
- throw new ProviderError(`Definition not found: ${guid}`, 404);
116
- const entry = existing.history.find((h) => h.ref === ref);
117
- if (!entry)
118
- throw new ProviderError(`History entry not found: ${ref}`, 404);
119
- const archived = await this.storage.get(definitionPaths.archive(guid, ref));
120
- if (!archived)
121
- throw new ProviderError(`Archived file not found for ref: ${ref}`, 404);
122
- // Archive the current file first, then restore the old one
123
- await this.updateFile(ctx, guid, archived, existing.fileExt, entry.originalName);
124
- }
125
- async delete(ctx, guid) {
126
- // Blobs first — if this fails, record remains and retry is safe.
127
- // If record delete fails after, the record points at nothing; the
128
- // next get() returns null-payload semantics and the janitor cleans up.
129
- await this.storage.deletePrefix(definitionPaths.prefix(guid));
130
- await this.data.definitions.delete(ctx, guid);
131
- }
132
- /**
133
- * Janitor — delete records stuck in 'pending' for longer than ageMs and
134
- * any blobs they may have written. Safe to run on a schedule.
135
- * Runs under SYSTEM_CONTEXT; callers don't pass one.
136
- *
137
- * @returns Number of records reclaimed.
138
- */
139
- async gcStalePending(ageMs = PENDING_GC_AGE_MS) {
140
- const cutoff = new Date(Date.now() - ageMs).toISOString();
141
- const stale = await this.data.definitions.listStalePending(SYSTEM_CONTEXT, cutoff);
142
- for (const record of stale) {
143
- await this.storage.deletePrefix(definitionPaths.prefix(record.guid));
144
- await this.data.definitions.delete(SYSTEM_CONTEXT, record.guid);
145
- }
146
- return stale.length;
147
- }
148
- }
149
- //# sourceMappingURL=service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/definitions/service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAO7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAa7C;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAE9D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,iBAAiB;IAEpB;IACA;IAFT,YACS,IAAmB,EACnB,OAAyB;QADzB,SAAI,GAAJ,IAAI,CAAe;QACnB,YAAO,GAAP,OAAO,CAAkB;IAC/B,CAAC;IAEJ,KAAK,CAAC,MAAM,CACX,GAAmB,EACnB,KAA4B,EAC5B,IAAgB;QAEhB,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,MAAM,GAAqB;YAChC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,OAAO,EAAE,EAAE;YACX,UAAU,EAAE,KAA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AI,CAAC,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9D,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,cAAc,CAAC,QAAgB,iBAAiB;QACrD,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QACnF,KAAK,MAAM,MAAM,IAAI,KAAK,EAAE,CAAC;YAC5B,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YACrE,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,KAAK,CAAC,MAAM,CAAC;IACrB,CAAC;CACD"}
@@ -1,146 +0,0 @@
1
- /**
2
- * Definition provider interfaces — independently swappable.
3
- *
4
- * File storage and metadata storage are deliberately split so you can mix:
5
- * - Filesystem files + Supabase DB metadata
6
- * - S3 files + local JSON metadata
7
- * - Everything through one backend (e.g. full Supabase)
8
- */
9
- export type DefinitionFileExt = 'gh' | 'ghx';
10
- /** File extensions accepted for Grasshopper definitions (with dot) */
11
- export declare const GH_EXTENSIONS: string[];
12
- /** Image extensions accepted for cover images (with dot) */
13
- export declare const COVER_IMAGE_EXTENSIONS: string[];
14
- /** All accepted upload extensions */
15
- export declare const ALLOWED_UPLOAD_EXTENSIONS: string[];
16
- /** MIME types for image extensions */
17
- export declare const COVER_IMAGE_CONTENT_TYPES: Record<string, string>;
18
- export interface DefinitionMeta {
19
- displayName: string;
20
- description?: string;
21
- category?: string;
22
- tags?: string[];
23
- /** Public URL to cover image, provider-dependent (e.g. /api/definitions/{guid}/image/cover.webp or a CDN URL) */
24
- coverImage?: string;
25
- /** Original uploaded filename, kept for display only */
26
- originalFilename?: string;
27
- }
28
- /**
29
- * A single entry in the file version history.
30
- * Stored by the meta provider; the actual bytes are stored by the file provider.
31
- */
32
- export interface HistoryEntry {
33
- /**
34
- * Provider-specific reference to the archived file.
35
- * Filesystem: timestamped filename (e.g. "2024-01-15T10-30-45-123Z_definition.gh").
36
- * S3 / Supabase: object key or storage path.
37
- */
38
- ref: string;
39
- /** Original uploaded filename, for display purposes */
40
- originalName: string;
41
- /** ISO 8601 date of when the file was archived */
42
- archivedAt: string;
43
- }
44
- export interface DefinitionRecord {
45
- /** UUID v4 primary key */
46
- guid: string;
47
- /** UUID of the project that owns this definition */
48
- projectId: string;
49
- /** UUID of the user who created this definition */
50
- ownerId: string;
51
- /**
52
- * Optional UUID of a specific compute server to use when solving.
53
- * Falls back to the org default, then the platform default.
54
- */
55
- computeServerId?: string;
56
- fileExt: DefinitionFileExt;
57
- meta: DefinitionMeta;
58
- /** File version history, newest first */
59
- history: HistoryEntry[];
60
- /** Maximum archived versions to keep. 0 = unlimited. */
61
- maxHistory: number;
62
- createdAt: string;
63
- updatedAt: string;
64
- }
65
- /**
66
- * File storage provider: where .gh / .ghx binaries, archived versions, and preview images live.
67
- *
68
- * Implement with: local filesystem, S3, Supabase Storage, Azure Blob, etc.
69
- */
70
- export interface IDefinitionFileProvider {
71
- /** Load the active Grasshopper definition binary. Returns null if not found. */
72
- getFile(guid: string): Promise<Uint8Array | null>;
73
- /** Load the preview image bytes. Returns null if no image exists. */
74
- getPreviewImage(guid: string): Promise<Uint8Array | null>;
75
- /**
76
- * Load an archived file by its provider-specific ref.
77
- * Used when reverting to a previous version.
78
- */
79
- getArchivedFile(guid: string, ref: string): Promise<Uint8Array | null>;
80
- /** Store the active definition file. Overwrites any existing active file. */
81
- saveFile(guid: string, data: Uint8Array, ext: DefinitionFileExt): Promise<void>;
82
- /**
83
- * Archive the current active file before replacing it.
84
- * Returns a HistoryEntry (with provider-specific ref) to be saved by the meta provider.
85
- * Returns null if there is no current active file to archive.
86
- */
87
- archiveCurrentFile(guid: string, originalName: string): Promise<HistoryEntry | null>;
88
- /**
89
- * Delete a specific archived version by its ref.
90
- * Called when pruning history that exceeds maxHistory.
91
- */
92
- deleteArchivedFile(guid: string, ref: string): Promise<void>;
93
- /** Store a preview image. The provider may transcode to its preferred format. */
94
- saveImage(guid: string, data: Uint8Array): Promise<void>;
95
- /**
96
- * Returns the public URL for the stored cover image after a saveImage() call.
97
- * Called immediately after saveImage() so the URL can be persisted in metadata.
98
- * Filesystem: returns "/api/definitions/{guid}/image/cover.webp".
99
- * S3/Supabase: returns the CDN or signed URL for the uploaded image.
100
- */
101
- getCoverImageUrl(guid: string): string;
102
- /** Delete all files associated with a GUID (active file, archives, image). */
103
- deleteFiles(guid: string): Promise<void>;
104
- }
105
- /**
106
- * Top-level fields that can be patched on an existing record.
107
- * `meta` is merged shallowly; top-level fields replace the stored value.
108
- */
109
- export interface DefinitionRecordPatch {
110
- meta?: Partial<DefinitionMeta>;
111
- fileExt?: DefinitionFileExt;
112
- maxHistory?: number;
113
- projectId?: string;
114
- computeServerId?: string | null;
115
- }
116
- /**
117
- * Metadata storage provider: where definition config, metadata, and file history live.
118
- *
119
- * Implement with: local JSON file, Supabase DB, DynamoDB, PostgreSQL, etc.
120
- */
121
- export interface IDefinitionMetaProvider {
122
- /** List all definition records, sorted by displayName. */
123
- list(): Promise<DefinitionRecord[]>;
124
- /** List all definitions belonging to a specific project. */
125
- listByProject(projectId: string): Promise<DefinitionRecord[]>;
126
- /** List definitions that belong to projects with public visibility. */
127
- listPublic(): Promise<DefinitionRecord[]>;
128
- /** Get a single record by GUID. Returns null if not found. */
129
- get(guid: string): Promise<DefinitionRecord | null>;
130
- /** Create a new definition record. */
131
- create(record: DefinitionRecord): Promise<void>;
132
- /** Merge a patch into an existing record. `meta` fields are merged shallowly. */
133
- update(guid: string, patch: DefinitionRecordPatch): Promise<void>;
134
- /**
135
- * Prepend a new history entry and optionally prune old entries.
136
- * The file provider has already archived the bytes; this just updates the metadata.
137
- */
138
- addHistoryEntry(guid: string, entry: HistoryEntry): Promise<void>;
139
- /**
140
- * Remove a history entry by ref (after the file provider has deleted the bytes).
141
- */
142
- removeHistoryEntry(guid: string, ref: string): Promise<void>;
143
- /** Delete a definition record entirely. */
144
- delete(guid: string): Promise<void>;
145
- }
146
- //# sourceMappingURL=definitions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../src/definitions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,iBAAiB,GAAG,IAAI,GAAG,KAAK,CAAC;AAE7C,sEAAsE;AACtE,eAAO,MAAM,aAAa,EAAE,MAAM,EAAoB,CAAC;AAEvD,4DAA4D;AAC5D,eAAO,MAAM,sBAAsB,EAAE,MAAM,EAA+C,CAAC;AAE3F,qCAAqC;AACrC,eAAO,MAAM,yBAAyB,EAAE,MAAM,EAAkD,CAAC;AAEjG,sCAAsC;AACtC,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAM5D,CAAC;AAEF,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,iHAAiH;IACjH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ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,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElE;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7D,2CAA2C;IAC3C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC"}
@@ -1,23 +0,0 @@
1
- /**
2
- * Definition provider interfaces — independently swappable.
3
- *
4
- * File storage and metadata storage are deliberately split so you can mix:
5
- * - Filesystem files + Supabase DB metadata
6
- * - S3 files + local JSON metadata
7
- * - Everything through one backend (e.g. full Supabase)
8
- */
9
- /** File extensions accepted for Grasshopper definitions (with dot) */
10
- export const GH_EXTENSIONS = ['.gh', '.ghx'];
11
- /** Image extensions accepted for cover images (with dot) */
12
- export const COVER_IMAGE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.webp', '.gif'];
13
- /** All accepted upload extensions */
14
- export const ALLOWED_UPLOAD_EXTENSIONS = [...GH_EXTENSIONS, ...COVER_IMAGE_EXTENSIONS];
15
- /** MIME types for image extensions */
16
- export const COVER_IMAGE_CONTENT_TYPES = {
17
- '.jpg': 'image/jpeg',
18
- '.jpeg': 'image/jpeg',
19
- '.png': 'image/png',
20
- '.webp': 'image/webp',
21
- '.gif': 'image/gif'
22
- };
23
- //# sourceMappingURL=definitions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../src/definitions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,sEAAsE;AACtE,MAAM,CAAC,MAAM,aAAa,GAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEvD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,sBAAsB,GAAa,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAE3F,qCAAqC;AACrC,MAAM,CAAC,MAAM,yBAAyB,GAAa,CAAC,GAAG,aAAa,EAAE,GAAG,sBAAsB,CAAC,CAAC;AAEjG,sCAAsC;AACtC,MAAM,CAAC,MAAM,yBAAyB,GAA2B;IAChE,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,WAAW;CACnB,CAAC"}
@@ -1,24 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const CreateInviteInputSchema: z.ZodObject<{
3
- email: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
4
- orgId: z.ZodString;
5
- orgRole: z.ZodEnum<{
6
- owner: "owner";
7
- admin: "admin";
8
- member: "member";
9
- }>;
10
- orgPermissions: z.ZodDefault<z.ZodArray<z.ZodEnum<{
11
- manage_org_members: "manage_org_members";
12
- manage_org_compute: "manage_org_compute";
13
- manage_definitions: "manage_definitions";
14
- manage_projects: "manage_projects";
15
- }>>>;
16
- }, z.core.$strip>;
17
- export declare const AcceptInviteInputSchema: z.ZodObject<{
18
- token: z.ZodString;
19
- password: z.ZodString;
20
- displayName: z.ZodOptional<z.ZodString>;
21
- }, z.core.$strip>;
22
- export type CreateInviteInput = z.infer<typeof CreateInviteInputSchema>;
23
- export type AcceptInviteInput = z.infer<typeof AcceptInviteInputSchema>;
24
- //# sourceMappingURL=schemas.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/invites/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;iBAQlC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;iBAIlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
@@ -1,17 +0,0 @@
1
- import { z } from 'zod';
2
- import { OrgRoleSchema, OrgPermissionSchema } from '../organizations/schemas.js';
3
- export const CreateInviteInputSchema = z.object({
4
- email: z
5
- .string()
6
- .email('Valid email is required')
7
- .transform((s) => s.toLowerCase()),
8
- orgId: z.string().uuid(),
9
- orgRole: OrgRoleSchema,
10
- orgPermissions: z.array(OrgPermissionSchema).default([])
11
- });
12
- export const AcceptInviteInputSchema = z.object({
13
- token: z.string().min(20),
14
- password: z.string().min(8, 'Password must be at least 8 characters'),
15
- displayName: z.string().trim().max(128).optional()
16
- });
17
- //# sourceMappingURL=schemas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/invites/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEjF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,KAAK,EAAE,CAAC;SACN,MAAM,EAAE;SACR,KAAK,CAAC,yBAAyB,CAAC;SAChC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACnC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IACxB,OAAO,EAAE,aAAa;IACtB,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CACxD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IACzB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wCAAwC,CAAC;IACrE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CAClD,CAAC,CAAC"}
@@ -1,93 +0,0 @@
1
- /**
2
- * Organization and Project provider interfaces.
3
- *
4
- * Models a three-level ownership hierarchy:
5
- * Platform → Organization → Project → Definition
6
- *
7
- * Implement for any backend:
8
- * - Local JSON files (built-in default)
9
- * - Supabase (row-level security tables)
10
- * - Firebase Firestore
11
- * - Any relational database
12
- */
13
- export interface Organization {
14
- /** UUID v4 primary key */
15
- id: string;
16
- /** Human-readable display name */
17
- name: string;
18
- /** URL-safe unique identifier, e.g. "acme-corp" */
19
- slug: string;
20
- /** UUID of the user who owns this org */
21
- ownerId: string;
22
- createdAt: string;
23
- updatedAt: string;
24
- }
25
- export type OrgRole = 'owner' | 'admin' | 'member';
26
- export interface OrgMember {
27
- orgId: string;
28
- userId: string;
29
- role: OrgRole;
30
- joinedAt: string;
31
- }
32
- /**
33
- * Who can invoke solve on definitions in this project:
34
- * - 'public' — any authenticated user
35
- * - 'org' — any member of the parent organization
36
- * - 'private' — only users listed in ProjectMember
37
- */
38
- export type ProjectVisibility = 'public' | 'org' | 'private';
39
- export type ProjectRole = 'owner' | 'editor' | 'viewer';
40
- export interface Project {
41
- /** UUID v4 primary key */
42
- id: string;
43
- /** UUID of the owning organization */
44
- orgId: string;
45
- name: string;
46
- /** URL-safe, unique within the organization */
47
- slug: string;
48
- description?: string;
49
- visibility: ProjectVisibility;
50
- /** UUID of the user who created this project */
51
- ownerId: string;
52
- createdAt: string;
53
- updatedAt: string;
54
- }
55
- export interface ProjectMember {
56
- projectId: string;
57
- userId: string;
58
- role: ProjectRole;
59
- joinedAt: string;
60
- }
61
- export interface IOrganizationProvider {
62
- listOrgs(): Promise<Organization[]>;
63
- getOrg(id: string): Promise<Organization | null>;
64
- getOrgBySlug(slug: string): Promise<Organization | null>;
65
- createOrg(org: Organization): Promise<void>;
66
- /** Patch mutable org fields. Only name and slug may be changed after creation. */
67
- updateOrg(id: string, patch: Partial<Pick<Organization, 'name' | 'slug'>>): Promise<void>;
68
- /** Delete an org and all its projects (cascade is implementation-specific). */
69
- deleteOrg(id: string): Promise<void>;
70
- listOrgMembers(orgId: string): Promise<OrgMember[]>;
71
- getOrgMember(orgId: string, userId: string): Promise<OrgMember | null>;
72
- addOrgMember(member: OrgMember): Promise<void>;
73
- updateOrgMemberRole(orgId: string, userId: string, role: OrgRole): Promise<void>;
74
- removeOrgMember(orgId: string, userId: string): Promise<void>;
75
- listProjects(orgId: string): Promise<Project[]>;
76
- getProject(id: string): Promise<Project | null>;
77
- getProjectBySlug(orgId: string, slug: string): Promise<Project | null>;
78
- createProject(project: Project): Promise<void>;
79
- updateProject(id: string, patch: Partial<Pick<Project, 'name' | 'slug' | 'description' | 'visibility'>>): Promise<void>;
80
- deleteProject(id: string): Promise<void>;
81
- listProjectMembers(projectId: string): Promise<ProjectMember[]>;
82
- getProjectMember(projectId: string, userId: string): Promise<ProjectMember | null>;
83
- addProjectMember(member: ProjectMember): Promise<void>;
84
- updateProjectMemberRole(projectId: string, userId: string, role: ProjectRole): Promise<void>;
85
- removeProjectMember(projectId: string, userId: string): Promise<void>;
86
- /** Returns true if the user may invoke solve on any definition in the project. */
87
- canSolve(userId: string, projectId: string): Promise<boolean>;
88
- /** Returns true if the user may upload or modify definitions in the project. */
89
- canEdit(userId: string, projectId: string): Promise<boolean>;
90
- /** Returns true if the user may manage project members and settings. */
91
- canManage(userId: string, projectId: string): Promise<boolean>;
92
- }
93
- //# sourceMappingURL=organizations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../src/organizations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,MAAM,WAAW,YAAY;IAC5B,0BAA0B;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,IAAI,EAAE,MAA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aAAa,CACZ,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,YAAY,CAAC,CAAC,GAC3E,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAIzC,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAChE,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACnF,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7F,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAMtE,kFAAkF;IAClF,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE9D,gFAAgF;IAChF,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE7D,wEAAwE;IACxE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/D"}
@@ -1,14 +0,0 @@
1
- /**
2
- * Organization and Project provider interfaces.
3
- *
4
- * Models a three-level ownership hierarchy:
5
- * Platform → Organization → Project → Definition
6
- *
7
- * Implement for any backend:
8
- * - Local JSON files (built-in default)
9
- * - Supabase (row-level security tables)
10
- * - Firebase Firestore
11
- * - Any relational database
12
- */
13
- export {};
14
- //# sourceMappingURL=organizations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"organizations.js","sourceRoot":"","sources":["../src/organizations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
@@ -1,33 +0,0 @@
1
- /**
2
- * Adapter conformance suite for IDefinitionStore.
3
- *
4
- * The goal is to prove every adapter behaves identically from the consuming
5
- * app's perspective — `ctx` scoping, `pending` filtering, `listStalePending`
6
- * cutoff, history mutations, and error shapes.
7
- *
8
- * Runner-agnostic: callers inject a `{ describe, it, expect }` trio so this
9
- * package stays test-framework free. For vitest or jest, pass the globals
10
- * directly; for node:test, wrap them.
11
- */
12
- import type { IDefinitionStore } from '../data/interface.js';
13
- export interface ConformanceRunner {
14
- describe: (name: string, fn: () => void) => void;
15
- it: (name: string, fn: () => Promise<void> | void) => void;
16
- expect: <T>(actual: T) => {
17
- toBe: (expected: T) => void;
18
- toEqual: (expected: unknown) => void;
19
- toBeNull: () => void;
20
- toBeTruthy: () => void;
21
- toContain: (expected: unknown) => void;
22
- };
23
- }
24
- export interface DefinitionStoreConformanceOptions {
25
- /** Name to show in the test output (e.g. "local-provider"). */
26
- name: string;
27
- /** Factory that returns a fresh, empty store per test. */
28
- createStore: () => Promise<IDefinitionStore> | IDefinitionStore;
29
- /** Test runner globals injected from the host package. */
30
- runner: ConformanceRunner;
31
- }
32
- export declare function runDefinitionStoreConformance(opts: DefinitionStoreConformanceOptions): void;
33
- //# sourceMappingURL=adapterSuite.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adapterSuite.d.ts","sourceRoot":"","sources":["../../src/testing/adapterSuite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAM7D,MAAM,WAAW,iBAAiB;IACjC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IACjD,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3D,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK;QACzB,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAC;QAC5B,OAAO,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;QACrC,QAAQ,EAAE,MAAM,IAAI,CAAC;QACrB,UAAU,EAAE,MAAM,IAAI,CAAC;QACvB,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;KACvC,CAAC;CACF;AAED,MAAM,WAAW,iCAAiC;IACjD,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,WAAW,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;IAChE,0DAA0D;IAC1D,MAAM,EAAE,iBAAiB,CAAC;CAC1B;AA4BD,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,iCAAiC,GAAG,IAAI,CA0J3F"}
@@ -1,166 +0,0 @@
1
- /**
2
- * Adapter conformance suite for IDefinitionStore.
3
- *
4
- * The goal is to prove every adapter behaves identically from the consuming
5
- * app's perspective — `ctx` scoping, `pending` filtering, `listStalePending`
6
- * cutoff, history mutations, and error shapes.
7
- *
8
- * Runner-agnostic: callers inject a `{ describe, it, expect }` trio so this
9
- * package stays test-framework free. For vitest or jest, pass the globals
10
- * directly; for node:test, wrap them.
11
- */
12
- import { SYSTEM_CONTEXT } from '../context.js';
13
- function ctx(userId, permissions = ['platform_admin']) {
14
- return { userId, permissions };
15
- }
16
- function record(overrides = {}) {
17
- const now = new Date().toISOString();
18
- return {
19
- guid: overrides.guid ?? cryptoRandom(),
20
- projectId: overrides.projectId ?? 'project-1',
21
- ownerId: overrides.ownerId ?? 'user-1',
22
- fileExt: overrides.fileExt ?? 'gh',
23
- meta: overrides.meta ?? { displayName: 'Test' },
24
- history: overrides.history ?? [],
25
- maxHistory: overrides.maxHistory ?? 10,
26
- status: overrides.status ?? 'ready',
27
- createdAt: overrides.createdAt ?? now,
28
- updatedAt: overrides.updatedAt ?? now,
29
- ...overrides
30
- };
31
- }
32
- // Minimal UUID-ish helper — good enough for tests, no crypto import needed.
33
- function cryptoRandom() {
34
- return `test-${Math.random().toString(36).slice(2, 10)}`;
35
- }
36
- export function runDefinitionStoreConformance(opts) {
37
- const { name, createStore, runner } = opts;
38
- const { describe, it, expect } = runner;
39
- describe(`IDefinitionStore conformance: ${name}`, () => {
40
- it('create + get returns the record', async () => {
41
- const store = await createStore();
42
- const rec = record({ guid: 'g1' });
43
- await store.create(ctx('u1'), rec);
44
- const got = await store.get(ctx('u1'), 'g1');
45
- expect(got?.guid).toBe('g1');
46
- });
47
- it('get returns null for missing guid', async () => {
48
- const store = await createStore();
49
- const got = await store.get(ctx('u1'), 'does-not-exist');
50
- expect(got).toBeNull();
51
- });
52
- it('list filters pending by default', async () => {
53
- const store = await createStore();
54
- await store.create(ctx('u1'), record({ guid: 'r1', status: 'ready' }));
55
- await store.create(ctx('u1'), record({ guid: 'p1', status: 'pending' }));
56
- const page = await store.list(ctx('u1'));
57
- const guids = page.items.map((r) => r.guid);
58
- expect(guids).toContain('r1');
59
- expect(guids.includes('p1')).toBe(false);
60
- });
61
- it('list with includePending returns pending too', async () => {
62
- const store = await createStore();
63
- await store.create(ctx('u1'), record({ guid: 'r1', status: 'ready' }));
64
- await store.create(ctx('u1'), record({ guid: 'p1', status: 'pending' }));
65
- const page = await store.list(ctx('u1'), { includePending: true });
66
- const guids = page.items.map((r) => r.guid);
67
- expect(guids).toContain('r1');
68
- expect(guids).toContain('p1');
69
- });
70
- it('listByProject filters by projectId', async () => {
71
- const store = await createStore();
72
- await store.create(ctx('u1'), record({ guid: 'a', projectId: 'proj-a' }));
73
- await store.create(ctx('u1'), record({ guid: 'b', projectId: 'proj-b' }));
74
- const page = await store.listByProject(ctx('u1'), 'proj-a');
75
- const guids = page.items.map((r) => r.guid);
76
- expect(guids).toEqual(['a']);
77
- });
78
- it('update applies patch and bumps updatedAt', async () => {
79
- const store = await createStore();
80
- const created = record({ guid: 'u1', meta: { displayName: 'Old' } });
81
- await store.create(ctx('u1'), created);
82
- await store.update(ctx('u1'), 'u1', { meta: { displayName: 'New' } });
83
- const got = await store.get(ctx('u1'), 'u1');
84
- expect(got?.meta.displayName).toBe('New');
85
- expect(got.updatedAt >= created.updatedAt).toBe(true);
86
- });
87
- it('update on missing guid throws ProviderError with status 404', async () => {
88
- const store = await createStore();
89
- let thrown;
90
- try {
91
- await store.update(ctx('u1'), 'nope', { meta: { displayName: 'X' } });
92
- }
93
- catch (err) {
94
- thrown = err;
95
- }
96
- expect(thrown).toBeTruthy();
97
- const e = thrown;
98
- expect(e.status).toBe(404);
99
- });
100
- it('status flip pending → ready via update', async () => {
101
- const store = await createStore();
102
- await store.create(ctx('u1'), record({ guid: 'x', status: 'pending' }));
103
- const beforeFlip = await store.list(ctx('u1'));
104
- expect(beforeFlip.items.map((r) => r.guid).includes('x')).toBe(false);
105
- await store.update(ctx('u1'), 'x', { status: 'ready' });
106
- const afterFlip = await store.list(ctx('u1'));
107
- expect(afterFlip.items.map((r) => r.guid)).toContain('x');
108
- });
109
- it('addHistoryEntry prepends entries (newest first)', async () => {
110
- const store = await createStore();
111
- await store.create(ctx('u1'), record({ guid: 'h', maxHistory: 0 }));
112
- const e1 = { ref: 'r1', originalName: 'a.gh', archivedAt: '2024-01-01' };
113
- const e2 = { ref: 'r2', originalName: 'b.gh', archivedAt: '2024-01-02' };
114
- await store.addHistoryEntry(ctx('u1'), 'h', e1);
115
- await store.addHistoryEntry(ctx('u1'), 'h', e2);
116
- const got = await store.get(ctx('u1'), 'h');
117
- expect(got.history.map((h) => h.ref)).toEqual(['r2', 'r1']);
118
- });
119
- it('removeHistoryEntry removes the matching ref', async () => {
120
- const store = await createStore();
121
- const entry = { ref: 'keep', originalName: 'a.gh', archivedAt: '2024-01-01' };
122
- const drop = { ref: 'drop', originalName: 'b.gh', archivedAt: '2024-01-02' };
123
- await store.create(ctx('u1'), record({ guid: 'h', history: [drop, entry] }));
124
- await store.removeHistoryEntry(ctx('u1'), 'h', 'drop');
125
- const got = await store.get(ctx('u1'), 'h');
126
- expect(got.history.map((h) => h.ref)).toEqual(['keep']);
127
- });
128
- it('delete removes the record', async () => {
129
- const store = await createStore();
130
- await store.create(ctx('u1'), record({ guid: 'd' }));
131
- await store.delete(ctx('u1'), 'd');
132
- const got = await store.get(ctx('u1'), 'd');
133
- expect(got).toBeNull();
134
- });
135
- it('listStalePending returns only pending + older than cutoff', async () => {
136
- const store = await createStore();
137
- const old = '2024-01-01T00:00:00.000Z';
138
- const recent = new Date().toISOString();
139
- await store.create(ctx('u1'), record({ guid: 'old-pending', status: 'pending', createdAt: old }));
140
- await store.create(ctx('u1'), record({ guid: 'new-pending', status: 'pending', createdAt: recent }));
141
- await store.create(ctx('u1'), record({ guid: 'old-ready', status: 'ready', createdAt: old }));
142
- const cutoff = '2024-06-01T00:00:00.000Z';
143
- const stale = await store.listStalePending(SYSTEM_CONTEXT, cutoff);
144
- const guids = stale.map((r) => r.guid);
145
- expect(guids).toContain('old-pending');
146
- expect(guids.includes('new-pending')).toBe(false);
147
- expect(guids.includes('old-ready')).toBe(false);
148
- });
149
- it('pagination respects limit and nextCursor', async () => {
150
- const store = await createStore();
151
- for (let i = 0; i < 5; i++) {
152
- await store.create(ctx('u1'), record({ guid: `p${i}`, meta: { displayName: `N${i}` } }));
153
- }
154
- const first = await store.list(ctx('u1'), { limit: 2 });
155
- expect(first.items.length).toBe(2);
156
- expect(first.nextCursor).toBeTruthy();
157
- const second = await store.list(ctx('u1'), { limit: 2, cursor: first.nextCursor });
158
- expect(second.items.length).toBe(2);
159
- const firstGuids = new Set(first.items.map((r) => r.guid));
160
- for (const item of second.items) {
161
- expect(firstGuids.has(item.guid)).toBe(false);
162
- }
163
- });
164
- });
165
- }
166
- //# sourceMappingURL=adapterSuite.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adapterSuite.js","sourceRoot":"","sources":["../../src/testing/adapterSuite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAwB/C,SAAS,GAAG,CAAC,MAAc,EAAE,cAA6C,CAAC,gBAAgB,CAAC;IAC3F,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAChC,CAAC;AAED,SAAS,MAAM,CAAC,YAAuC,EAAE;IACxD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO;QACN,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,YAAY,EAAE;QACtC,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,WAAW;QAC7C,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,QAAQ;QACtC,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,IAAI;QAClC,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE;QAC/C,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE;QAChC,UAAU,EAAE,SAAS,CAAC,UAAU,IAAI,EAAE;QACtC,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI,OAAO;QACnC,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,GAAG;QACrC,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,GAAG;QACrC,GAAG,SAAS;KACZ,CAAC;AACH,CAAC;AAED,4EAA4E;AAC5E,SAAS,YAAY;IACpB,OAAO,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,C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K,CAAC,UAAU,CAAC,CAAC,UAAU,EAAE,CAAC;YAEtC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;YACnF,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACpC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/C,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC"}
@@ -1,21 +0,0 @@
1
- import type { RequestContext } from '../../context.js';
2
- export interface ConformanceExpect<T> {
3
- toBe: (expected: T) => void;
4
- toEqual: (expected: unknown) => void;
5
- toBeNull: () => void;
6
- toBeTruthy: () => void;
7
- toBeFalsy: () => void;
8
- toContain: (expected: unknown) => void;
9
- toBeLessThanOrEqual: (expected: number) => void;
10
- toThrow: (expected?: any) => void;
11
- resolves: ConformanceExpect<Awaited<T>>;
12
- not: ConformanceExpect<T>;
13
- }
14
- export interface ConformanceRunner {
15
- describe: (name: string, fn: () => void) => void;
16
- it: (name: string, fn: () => Promise<void> | void) => void;
17
- expect: <T>(actual: T) => ConformanceExpect<T>;
18
- }
19
- export declare function makeCtx(userId: string, permissions?: RequestContext['permissions']): RequestContext;
20
- export declare function makeUuid(): string;
21
- //# sourceMappingURL=runner.d.ts.map
@@ -1 +0,0 @@
1
- {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function makeCtx(userId, permissions = ['platform_admin']) {
2
- return { userId, permissions };
3
- }
4
- export function makeUuid() {
5
- return crypto.randomUUID();
6
- }
7
- //# sourceMappingURL=runner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../src/testing/suites/runner.ts"],"names":[],"mappings":"AAsBA,MAAM,UAAU,OAAO,CACtB,MAAc,EACd,cAA6C,CAAC,gBAAgB,CAAC;IAE/D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,QAAQ;IACvB,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;AAC5B,CAAC"}