scribase 0.1.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/README.md +220 -0
- package/dist/cli/credentials.d.ts +35 -0
- package/dist/cli/credentials.d.ts.map +1 -0
- package/dist/cli/credentials.js +125 -0
- package/dist/cli/credentials.js.map +1 -0
- package/dist/cli/envfile.d.ts +20 -0
- package/dist/cli/envfile.d.ts.map +1 -0
- package/dist/cli/envfile.js +86 -0
- package/dist/cli/envfile.js.map +1 -0
- package/dist/cli/framework.d.ts +45 -0
- package/dist/cli/framework.d.ts.map +1 -0
- package/dist/cli/framework.js +107 -0
- package/dist/cli/framework.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +239 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +118 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +455 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/login.d.ts +104 -0
- package/dist/cli/login.d.ts.map +1 -0
- package/dist/cli/login.js +306 -0
- package/dist/cli/login.js.map +1 -0
- package/dist/cli/pow.d.ts +9 -0
- package/dist/cli/pow.d.ts.map +1 -0
- package/dist/cli/pow.js +31 -0
- package/dist/cli/pow.js.map +1 -0
- package/dist/cli/vercel.d.ts +92 -0
- package/dist/cli/vercel.d.ts.map +1 -0
- package/dist/cli/vercel.js +230 -0
- package/dist/cli/vercel.js.map +1 -0
- package/dist/client.d.ts +137 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +311 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +79 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +139 -0
- package/dist/errors.js.map +1 -0
- package/dist/evidence.d.ts +78 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +36 -0
- package/dist/evidence.js.map +1 -0
- package/dist/idempotency.d.ts +24 -0
- package/dist/idempotency.d.ts.map +1 -0
- package/dist/idempotency.js +59 -0
- package/dist/idempotency.js.map +1 -0
- package/dist/importers/firebase.d.ts +101 -0
- package/dist/importers/firebase.d.ts.map +1 -0
- package/dist/importers/firebase.js +251 -0
- package/dist/importers/firebase.js.map +1 -0
- package/dist/importers/index.d.ts +11 -0
- package/dist/importers/index.d.ts.map +1 -0
- package/dist/importers/index.js +9 -0
- package/dist/importers/index.js.map +1 -0
- package/dist/importers/instantdb.d.ts +76 -0
- package/dist/importers/instantdb.d.ts.map +1 -0
- package/dist/importers/instantdb.js +152 -0
- package/dist/importers/instantdb.js.map +1 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/pagination.d.ts +33 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +68 -0
- package/dist/pagination.js.map +1 -0
- package/dist/resources/account.d.ts +156 -0
- package/dist/resources/account.d.ts.map +1 -0
- package/dist/resources/account.js +114 -0
- package/dist/resources/account.js.map +1 -0
- package/dist/resources/audit.d.ts +26 -0
- package/dist/resources/audit.d.ts.map +1 -0
- package/dist/resources/audit.js +43 -0
- package/dist/resources/audit.js.map +1 -0
- package/dist/resources/auth.d.ts +149 -0
- package/dist/resources/auth.d.ts.map +1 -0
- package/dist/resources/auth.js +70 -0
- package/dist/resources/auth.js.map +1 -0
- package/dist/resources/backups.d.ts +117 -0
- package/dist/resources/backups.d.ts.map +1 -0
- package/dist/resources/backups.js +92 -0
- package/dist/resources/backups.js.map +1 -0
- package/dist/resources/branches.d.ts +151 -0
- package/dist/resources/branches.d.ts.map +1 -0
- package/dist/resources/branches.js +62 -0
- package/dist/resources/branches.js.map +1 -0
- package/dist/resources/database.d.ts +107 -0
- package/dist/resources/database.d.ts.map +1 -0
- package/dist/resources/database.js +54 -0
- package/dist/resources/database.js.map +1 -0
- package/dist/resources/environments.d.ts +106 -0
- package/dist/resources/environments.d.ts.map +1 -0
- package/dist/resources/environments.js +131 -0
- package/dist/resources/environments.js.map +1 -0
- package/dist/resources/export.d.ts +101 -0
- package/dist/resources/export.d.ts.map +1 -0
- package/dist/resources/export.js +89 -0
- package/dist/resources/export.js.map +1 -0
- package/dist/resources/functions.d.ts +75 -0
- package/dist/resources/functions.d.ts.map +1 -0
- package/dist/resources/functions.js +58 -0
- package/dist/resources/functions.js.map +1 -0
- package/dist/resources/imports.d.ts +183 -0
- package/dist/resources/imports.d.ts.map +1 -0
- package/dist/resources/imports.js +168 -0
- package/dist/resources/imports.js.map +1 -0
- package/dist/resources/insights.d.ts +50 -0
- package/dist/resources/insights.d.ts.map +1 -0
- package/dist/resources/insights.js +21 -0
- package/dist/resources/insights.js.map +1 -0
- package/dist/resources/metrics.d.ts +61 -0
- package/dist/resources/metrics.d.ts.map +1 -0
- package/dist/resources/metrics.js +23 -0
- package/dist/resources/metrics.js.map +1 -0
- package/dist/resources/migrations.d.ts +24 -0
- package/dist/resources/migrations.d.ts.map +1 -0
- package/dist/resources/migrations.js +29 -0
- package/dist/resources/migrations.js.map +1 -0
- package/dist/resources/operations.d.ts +37 -0
- package/dist/resources/operations.d.ts.map +1 -0
- package/dist/resources/operations.js +81 -0
- package/dist/resources/operations.js.map +1 -0
- package/dist/resources/organizations.d.ts +171 -0
- package/dist/resources/organizations.d.ts.map +1 -0
- package/dist/resources/organizations.js +180 -0
- package/dist/resources/organizations.js.map +1 -0
- package/dist/resources/previews.d.ts +49 -0
- package/dist/resources/previews.d.ts.map +1 -0
- package/dist/resources/previews.js +62 -0
- package/dist/resources/previews.js.map +1 -0
- package/dist/resources/projects.d.ts +73 -0
- package/dist/resources/projects.d.ts.map +1 -0
- package/dist/resources/projects.js +84 -0
- package/dist/resources/projects.js.map +1 -0
- package/dist/resources/queues.d.ts +100 -0
- package/dist/resources/queues.d.ts.map +1 -0
- package/dist/resources/queues.js +77 -0
- package/dist/resources/queues.js.map +1 -0
- package/dist/resources/realtime.d.ts +37 -0
- package/dist/resources/realtime.d.ts.map +1 -0
- package/dist/resources/realtime.js +23 -0
- package/dist/resources/realtime.js.map +1 -0
- package/dist/resources/restores.d.ts +67 -0
- package/dist/resources/restores.d.ts.map +1 -0
- package/dist/resources/restores.js +90 -0
- package/dist/resources/restores.js.map +1 -0
- package/dist/resources/storage.d.ts +50 -0
- package/dist/resources/storage.d.ts.map +1 -0
- package/dist/resources/storage.js +38 -0
- package/dist/resources/storage.js.map +1 -0
- package/dist/resources/usage.d.ts +85 -0
- package/dist/resources/usage.d.ts.map +1 -0
- package/dist/resources/usage.js +37 -0
- package/dist/resources/usage.js.map +1 -0
- package/dist/types.gen.d.ts +473 -0
- package/dist/types.gen.d.ts.map +1 -0
- package/dist/types.gen.js +8 -0
- package/dist/types.gen.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { HttpTransport } from '../client.js';
|
|
2
|
+
import type { EnvironmentRef } from './environments.js';
|
|
3
|
+
import type { CreateExportRequest, ExportFormat, ExportResult, PortableIdentifier } from '../types.gen.js';
|
|
4
|
+
import type { ProjectRef } from './branches.js';
|
|
5
|
+
/** Body of {@link ExportResource.createForProject}. */
|
|
6
|
+
export interface ProjectExportRequest {
|
|
7
|
+
/** The environment whose database is dumped into the bundle. */
|
|
8
|
+
sourceEnvironmentId: PortableIdentifier;
|
|
9
|
+
/** Defaults to `compose` on the server. */
|
|
10
|
+
format?: ExportFormat;
|
|
11
|
+
}
|
|
12
|
+
/** Lifecycle of a registered export bundle. */
|
|
13
|
+
export type ExportState = 'requested' | 'running' | 'available' | 'failed' | 'expired';
|
|
14
|
+
/**
|
|
15
|
+
* One export in the control plane's export registry
|
|
16
|
+
* (`GET …/projects/{project}/exports`, `GET /v1/organizations/{org}/exports/{id}`).
|
|
17
|
+
* `download_url` is an API-relative, time-limited signed link present once the
|
|
18
|
+
* bundle is `available`; follow it with {@link ExportResource.download}.
|
|
19
|
+
*/
|
|
20
|
+
export interface ExportRecord {
|
|
21
|
+
export_id: PortableIdentifier;
|
|
22
|
+
project: {
|
|
23
|
+
organization_id: PortableIdentifier;
|
|
24
|
+
project_id: PortableIdentifier;
|
|
25
|
+
};
|
|
26
|
+
source_environment_id: PortableIdentifier;
|
|
27
|
+
state: ExportState | (string & {});
|
|
28
|
+
format: ExportFormat | (string & {});
|
|
29
|
+
include_data: boolean;
|
|
30
|
+
include_storage: boolean;
|
|
31
|
+
created_at_epoch_seconds: number;
|
|
32
|
+
total_size_bytes: number;
|
|
33
|
+
sha256: string;
|
|
34
|
+
postgres_major: number;
|
|
35
|
+
artifacts: unknown[];
|
|
36
|
+
boots_elsewhere: boolean;
|
|
37
|
+
storage_object_count: number;
|
|
38
|
+
expires_at_epoch_seconds?: number;
|
|
39
|
+
boot_check?: string;
|
|
40
|
+
error?: string;
|
|
41
|
+
download_url?: string;
|
|
42
|
+
}
|
|
43
|
+
/** `GET …/projects/{project}/exports` body. */
|
|
44
|
+
export interface ListExportsResponse {
|
|
45
|
+
items: ExportRecord[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* `POST …/environments/{env}/exports` body. The wire model is the generated
|
|
49
|
+
* {@link CreateExportRequest}; this is the client-facing name for it.
|
|
50
|
+
*
|
|
51
|
+
* "No export path" is the competitor's structural weakness; a *runnable* export
|
|
52
|
+
* is the answer, so a bundle boots from either a Docker Compose file or a
|
|
53
|
+
* Kustomize overlay (see {@link ExportFormat}).
|
|
54
|
+
*/
|
|
55
|
+
export type ExportRequest = CreateExportRequest;
|
|
56
|
+
export type { ExportFormat, ExportIntegrityClaim, ExportDatabaseArtifact, ExportStorageSummary, ExportManifestSignature, ExportManifest, ExportResult, } from '../types.gen.js';
|
|
57
|
+
/**
|
|
58
|
+
* Export bundles for one environment. `create` assembles a runnable bundle and
|
|
59
|
+
* a signed manifest and returns both. Backs `scribase export`.
|
|
60
|
+
*/
|
|
61
|
+
export declare class ExportResource {
|
|
62
|
+
#private;
|
|
63
|
+
constructor(http: HttpTransport);
|
|
64
|
+
/** `POST …/environments/{env}/exports` — assemble a signed, runnable bundle. */
|
|
65
|
+
create(ref: EnvironmentRef, request: ExportRequest, options?: {
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
}): Promise<ExportResult>;
|
|
68
|
+
/**
|
|
69
|
+
* `POST /v1/organizations/{org}/projects/{project}/export` — the
|
|
70
|
+
* project-scoped form: the source environment travels in the body.
|
|
71
|
+
*/
|
|
72
|
+
createForProject(ref: ProjectRef, request: ProjectExportRequest, options?: {
|
|
73
|
+
signal?: AbortSignal;
|
|
74
|
+
}): Promise<ExportResult>;
|
|
75
|
+
/**
|
|
76
|
+
* `GET /v1/organizations/{org}/projects/{project}/exports` — the project's
|
|
77
|
+
* registered exports, newest first, each with its state and (once available)
|
|
78
|
+
* a signed `download_url`.
|
|
79
|
+
*/
|
|
80
|
+
list(ref: ProjectRef): Promise<ExportRecord[]>;
|
|
81
|
+
/**
|
|
82
|
+
* `GET /v1/organizations/{org}/exports/{exportId}` — one registered export,
|
|
83
|
+
* with a freshly signed `download_url` when the bundle is available.
|
|
84
|
+
*/
|
|
85
|
+
getManifest(organizationId: PortableIdentifier, exportId: PortableIdentifier): Promise<ExportRecord>;
|
|
86
|
+
/**
|
|
87
|
+
* The absolute-path signed download link for an available export, or `null`
|
|
88
|
+
* while the bundle is still being built (or after it failed or expired).
|
|
89
|
+
* Links are short-lived; call this right before downloading.
|
|
90
|
+
*/
|
|
91
|
+
downloadUrl(organizationId: PortableIdentifier, exportId: PortableIdentifier): Promise<string | null>;
|
|
92
|
+
/**
|
|
93
|
+
* Download an available export bundle (`.tar.gz`) as a Blob by following a
|
|
94
|
+
* freshly signed `GET /v1/organizations/{org}/exports/{id}/download` link.
|
|
95
|
+
* Rejects when the export is not available yet.
|
|
96
|
+
*/
|
|
97
|
+
download(organizationId: PortableIdentifier, exportId: PortableIdentifier, options?: {
|
|
98
|
+
signal?: AbortSignal;
|
|
99
|
+
}): Promise<Blob>;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/resources/export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAEZ,YAAY,EACZ,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,uDAAuD;AACvD,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,mBAAmB,EAAE,kBAAkB,CAAC;IACxC,2CAA2C;IAC3C,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,+CAA+C;AAC/C,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEvF;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,OAAO,EAAE;QAAE,eAAe,EAAE,kBAAkB,CAAC;QAAC,UAAU,EAAE,kBAAkB,CAAA;KAAE,CAAC;IACjF,qBAAqB,EAAE,kBAAkB,CAAC;IAC1C,KAAK,EAAE,WAAW,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACnC,MAAM,EAAE,YAAY,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACrC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;IACzB,wBAAwB,EAAE,MAAM,CAAC;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,eAAe,EAAE,OAAO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cAAc,EAAE,kBAAkB,EAClC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACjC,OAAO,CAAC,IAAI,CAAC;CAUjB"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { environmentPath } from './environments.js';
|
|
2
|
+
/**
|
|
3
|
+
* Export bundles for one environment. `create` assembles a runnable bundle and
|
|
4
|
+
* a signed manifest and returns both. Backs `scribase export`.
|
|
5
|
+
*/
|
|
6
|
+
export class ExportResource {
|
|
7
|
+
#http;
|
|
8
|
+
constructor(http) {
|
|
9
|
+
this.#http = http;
|
|
10
|
+
}
|
|
11
|
+
/** `POST …/environments/{env}/exports` — assemble a signed, runnable bundle. */
|
|
12
|
+
async create(ref, request, options) {
|
|
13
|
+
const result = await this.#http.send({
|
|
14
|
+
method: 'POST',
|
|
15
|
+
path: `${environmentPath(ref)}/exports`,
|
|
16
|
+
body: request,
|
|
17
|
+
...(options?.signal ? { signal: options.signal } : {}),
|
|
18
|
+
});
|
|
19
|
+
return result.data;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `POST /v1/organizations/{org}/projects/{project}/export` — the
|
|
23
|
+
* project-scoped form: the source environment travels in the body.
|
|
24
|
+
*/
|
|
25
|
+
async createForProject(ref, request, options) {
|
|
26
|
+
const result = await this.#http.send({
|
|
27
|
+
method: 'POST',
|
|
28
|
+
path: `${projectPath(ref)}/export`,
|
|
29
|
+
body: {
|
|
30
|
+
source_environment_id: request.sourceEnvironmentId,
|
|
31
|
+
...(request.format !== undefined ? { format: request.format } : {}),
|
|
32
|
+
},
|
|
33
|
+
...(options?.signal ? { signal: options.signal } : {}),
|
|
34
|
+
});
|
|
35
|
+
return result.data;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `GET /v1/organizations/{org}/projects/{project}/exports` — the project's
|
|
39
|
+
* registered exports, newest first, each with its state and (once available)
|
|
40
|
+
* a signed `download_url`.
|
|
41
|
+
*/
|
|
42
|
+
async list(ref) {
|
|
43
|
+
const result = await this.#http.send({
|
|
44
|
+
method: 'GET',
|
|
45
|
+
path: `${projectPath(ref)}/exports`,
|
|
46
|
+
});
|
|
47
|
+
return result.data.items;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* `GET /v1/organizations/{org}/exports/{exportId}` — one registered export,
|
|
51
|
+
* with a freshly signed `download_url` when the bundle is available.
|
|
52
|
+
*/
|
|
53
|
+
async getManifest(organizationId, exportId) {
|
|
54
|
+
const result = await this.#http.send({
|
|
55
|
+
method: 'GET',
|
|
56
|
+
path: `/v1/organizations/${encodeURIComponent(organizationId)}/exports/${encodeURIComponent(exportId)}`,
|
|
57
|
+
});
|
|
58
|
+
return result.data;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The absolute-path signed download link for an available export, or `null`
|
|
62
|
+
* while the bundle is still being built (or after it failed or expired).
|
|
63
|
+
* Links are short-lived; call this right before downloading.
|
|
64
|
+
*/
|
|
65
|
+
async downloadUrl(organizationId, exportId) {
|
|
66
|
+
const record = await this.getManifest(organizationId, exportId);
|
|
67
|
+
return record.state === 'available' && record.download_url ? record.download_url : null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Download an available export bundle (`.tar.gz`) as a Blob by following a
|
|
71
|
+
* freshly signed `GET /v1/organizations/{org}/exports/{id}/download` link.
|
|
72
|
+
* Rejects when the export is not available yet.
|
|
73
|
+
*/
|
|
74
|
+
async download(organizationId, exportId, options) {
|
|
75
|
+
const url = await this.downloadUrl(organizationId, exportId);
|
|
76
|
+
if (url === null) {
|
|
77
|
+
throw new Error(`export ${exportId} is not available for download yet`);
|
|
78
|
+
}
|
|
79
|
+
if (!this.#http.downloadBlob) {
|
|
80
|
+
throw new TypeError('the configured transport cannot download binary content');
|
|
81
|
+
}
|
|
82
|
+
return this.#http.downloadBlob(url, options);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function projectPath(ref) {
|
|
86
|
+
return (`/v1/organizations/${encodeURIComponent(ref.organizationId)}` +
|
|
87
|
+
`/projects/${encodeURIComponent(ref.projectId)}`);
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/resources/export.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AA4EpD;;;GAGG;AACH,MAAM,OAAO,cAAc;IAChB,KAAK,CAAgB;IAE9B,YAAY,IAAmB;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,gFAAgF;IAChF,KAAK,CAAC,MAAM,CACV,GAAmB,EACnB,OAAsB,EACtB,OAAkC;QAElC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAe;YACjD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,GAAG,eAAe,CAAC,GAAG,CAAC,UAAU;YACvC,IAAI,EAAE,OAAO;YACb,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvD,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,gBAAgB,CACpB,GAAe,EACf,OAA6B,EAC7B,OAAkC;QAElC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAe;YACjD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS;YAClC,IAAI,EAAE;gBACJ,qBAAqB,EAAE,OAAO,CAAC,mBAAmB;gBAClD,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAA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AAG,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QAC7D,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,UAAU,QAAQ,oCAAoC,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;YAC7B,MAAM,IAAI,SAAS,CAAC,yDAAyD,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;CACF;AAED,SAAS,WAAW,CAAC,GAAe;IAClC,OAAO,CACL,qBAAqB,kBAAkB,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE;QAC7D,aAAa,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CACjD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { HttpTransport } from '../client.js';
|
|
2
|
+
import type { EnvironmentReference } from '../types.gen.js';
|
|
3
|
+
import type { EnvironmentRef } from './environments.js';
|
|
4
|
+
/** Response of {@link FunctionsResource.list}. */
|
|
5
|
+
export interface FunctionsList {
|
|
6
|
+
/** The environment the inventory belongs to. */
|
|
7
|
+
environment: EnvironmentReference;
|
|
8
|
+
/**
|
|
9
|
+
* The deployed edge functions, opaque function records. Empty when the runtime
|
|
10
|
+
* is unreachable or has no functions deployed yet.
|
|
11
|
+
*/
|
|
12
|
+
functions: unknown[];
|
|
13
|
+
/**
|
|
14
|
+
* Present only when the list was degraded to empty; explains why. `null` on a
|
|
15
|
+
* healthy, populated response.
|
|
16
|
+
*/
|
|
17
|
+
notes: string | null;
|
|
18
|
+
}
|
|
19
|
+
/** Body of {@link FunctionsResource.deploy}. Pass `source`, `files`, or both. */
|
|
20
|
+
export interface DeployFunctionRequest {
|
|
21
|
+
/** Letters, digits, hyphens, or underscores. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** The entrypoint's source code. */
|
|
24
|
+
source?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Every module of a multi-file function, keyed by path relative to
|
|
27
|
+
* `supabase/functions` (`hello/index.ts`, `_shared/cors.ts`), with
|
|
28
|
+
* `entrypoint: 'hello/index.ts'`. No `..` segments.
|
|
29
|
+
*/
|
|
30
|
+
files?: Record<string, string>;
|
|
31
|
+
/** `index.ts` (default) or `<directory>/index.ts` inside `files`. */
|
|
32
|
+
entrypoint?: string;
|
|
33
|
+
/** A Deno import map (`{ imports: { ... } }`). */
|
|
34
|
+
import_map?: {
|
|
35
|
+
imports?: Record<string, string>;
|
|
36
|
+
scopes?: Record<string, Record<string, string>>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Require a valid project JWT (`apikey` or `Authorization`) on every call.
|
|
40
|
+
* Defaults to true on the runtime, like `verify_jwt` in `supabase/config.toml`.
|
|
41
|
+
*/
|
|
42
|
+
verify_jwt?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Envelope of a deploy or invoke: the function name and the runtime's reply.
|
|
46
|
+
* `result` is the runtime's JSON verbatim, or its text body as a string.
|
|
47
|
+
*/
|
|
48
|
+
export interface FunctionResult<T = unknown> {
|
|
49
|
+
function: string;
|
|
50
|
+
result: T;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Functions — the edge-functions inventory for an environment. Lists
|
|
54
|
+
* the environment's deployed functions and their status via the control plane's
|
|
55
|
+
* server-side proxy to the per-env functions runtime admin API. The read degrades
|
|
56
|
+
* softly: an unreachable or not-yet-deployed runtime yields an empty list plus a
|
|
57
|
+
* `notes` string explaining the empty state.
|
|
58
|
+
*/
|
|
59
|
+
export declare class FunctionsResource {
|
|
60
|
+
#private;
|
|
61
|
+
constructor(http: HttpTransport);
|
|
62
|
+
/** `GET …/environments/{env}/functions` — the environment's edge functions. */
|
|
63
|
+
list(ref: EnvironmentRef): Promise<FunctionsList>;
|
|
64
|
+
/**
|
|
65
|
+
* `POST …/environments/{env}/functions` — deploy (create or replace) a
|
|
66
|
+
* function. Unlike the list, a failed deploy surfaces as an error.
|
|
67
|
+
*/
|
|
68
|
+
deploy(ref: EnvironmentRef, request: DeployFunctionRequest): Promise<FunctionResult>;
|
|
69
|
+
/**
|
|
70
|
+
* `POST …/environments/{env}/functions/{name}/invoke` — invoke a deployed
|
|
71
|
+
* function with an optional JSON payload.
|
|
72
|
+
*/
|
|
73
|
+
invoke<T = unknown>(ref: EnvironmentRef, name: string, payload?: Record<string, unknown>): Promise<FunctionResult<T>>;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/resources/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,kDAAkD;AAClD,MAAM,WAAW,aAAa;IAC5B,gDAAgD;IAChD,WAAW,EAAE,oBAAoB,CAAC;IAClC;;;OAGG;IACH,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,iFAAiF;AACjF,MAAM,WAAW,qBAAqB;IACpC,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,UAAU,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;KAAE,CAAC;IACnG;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,CAAC,CAAC;CACX;AAID;;;;;;GAMG;AACH,qBAAa,iBAAiB;;gBAGhB,IAAI,EAAE,aAAa;IAI/B,+EAA+E;IACzE,IAAI,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAQvD;;;OAGG;IACG,MAAM,CAAC,GAAG,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;IAa1F;;;OAGG;IACG,MAAM,CAAC,CAAC,GAAG,OAAO,EACtB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACpC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CAS9B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { environmentPath } from './environments.js';
|
|
2
|
+
const FUNCTION_NAME = /^[A-Za-z0-9_-]+$/;
|
|
3
|
+
/**
|
|
4
|
+
* Functions — the edge-functions inventory for an environment. Lists
|
|
5
|
+
* the environment's deployed functions and their status via the control plane's
|
|
6
|
+
* server-side proxy to the per-env functions runtime admin API. The read degrades
|
|
7
|
+
* softly: an unreachable or not-yet-deployed runtime yields an empty list plus a
|
|
8
|
+
* `notes` string explaining the empty state.
|
|
9
|
+
*/
|
|
10
|
+
export class FunctionsResource {
|
|
11
|
+
#http;
|
|
12
|
+
constructor(http) {
|
|
13
|
+
this.#http = http;
|
|
14
|
+
}
|
|
15
|
+
/** `GET …/environments/{env}/functions` — the environment's edge functions. */
|
|
16
|
+
async list(ref) {
|
|
17
|
+
const result = await this.#http.send({
|
|
18
|
+
method: 'GET',
|
|
19
|
+
path: `${environmentPath(ref)}/functions`,
|
|
20
|
+
});
|
|
21
|
+
return result.data;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* `POST …/environments/{env}/functions` — deploy (create or replace) a
|
|
25
|
+
* function. Unlike the list, a failed deploy surfaces as an error.
|
|
26
|
+
*/
|
|
27
|
+
async deploy(ref, request) {
|
|
28
|
+
assertFunctionName(request.name);
|
|
29
|
+
if (request.source === undefined && request.files === undefined) {
|
|
30
|
+
throw new RangeError('deploy needs source or files');
|
|
31
|
+
}
|
|
32
|
+
const result = await this.#http.send({
|
|
33
|
+
method: 'POST',
|
|
34
|
+
path: `${environmentPath(ref)}/functions`,
|
|
35
|
+
body: request,
|
|
36
|
+
});
|
|
37
|
+
return result.data;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* `POST …/environments/{env}/functions/{name}/invoke` — invoke a deployed
|
|
41
|
+
* function with an optional JSON payload.
|
|
42
|
+
*/
|
|
43
|
+
async invoke(ref, name, payload = {}) {
|
|
44
|
+
assertFunctionName(name);
|
|
45
|
+
const result = await this.#http.send({
|
|
46
|
+
method: 'POST',
|
|
47
|
+
path: `${environmentPath(ref)}/functions/${encodeURIComponent(name)}/invoke`,
|
|
48
|
+
body: payload,
|
|
49
|
+
});
|
|
50
|
+
return result.data;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function assertFunctionName(name) {
|
|
54
|
+
if (!FUNCTION_NAME.test(name)) {
|
|
55
|
+
throw new RangeError('function name must be letters, digits, hyphens, or underscores');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/resources/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I,EAAE,GAAG,eAAe,CAAC,GAAG,CAAC,cAAc,kBAAkB,CAAC,IAAI,CAAC,SAAS;YAC5E,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;CACF;AAED,SAAS,kBAAkB,CAAC,IAAY;IACtC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,UAAU,CAAC,gEAAgE,CAAC,CAAC;IACzF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { HttpTransport } from '../client.js';
|
|
2
|
+
import type { CreateImportRequest, ImportDestination, ImportDryRun, ImportJob, ImportReport, PortableIdentifier } from '../types.gen.js';
|
|
3
|
+
/** One persisted import run, as listed by {@link ImportsResource.history}. */
|
|
4
|
+
export interface ImportSummary {
|
|
5
|
+
import_id: PortableIdentifier;
|
|
6
|
+
project_id: PortableIdentifier;
|
|
7
|
+
environment_id: PortableIdentifier;
|
|
8
|
+
source_project_ref: string;
|
|
9
|
+
dry_run: boolean;
|
|
10
|
+
/** Epoch seconds the run was recorded. */
|
|
11
|
+
created_at: number;
|
|
12
|
+
/** Whether verification passed; absent for dry runs. */
|
|
13
|
+
passed?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** A persisted run in full: the summary plus the exact body the import returned. */
|
|
16
|
+
export interface ImportRecord extends ImportSummary {
|
|
17
|
+
report: ImportReport | ImportDryRun;
|
|
18
|
+
}
|
|
19
|
+
export interface ImportHistoryParams {
|
|
20
|
+
/** 1..200. */
|
|
21
|
+
limit?: number;
|
|
22
|
+
}
|
|
23
|
+
/** Where an import reads from. */
|
|
24
|
+
export type ImportSource = 'supabase' | 'firebase' | 'instantdb';
|
|
25
|
+
/**
|
|
26
|
+
* Optional login proof: `email` alone checks the user's id and password hash
|
|
27
|
+
* arrived unchanged; with `password` it proves a real sign-in succeeds.
|
|
28
|
+
*/
|
|
29
|
+
export interface ImportLoginProof {
|
|
30
|
+
email: string;
|
|
31
|
+
password?: string;
|
|
32
|
+
}
|
|
33
|
+
interface ImportRequestCommon {
|
|
34
|
+
destination: ImportDestination;
|
|
35
|
+
/** Copy storage buckets and objects (default true). */
|
|
36
|
+
includeStorage?: boolean;
|
|
37
|
+
verifyLogin?: ImportLoginProof;
|
|
38
|
+
}
|
|
39
|
+
/** A live Supabase project (the classic request, with optional extras). */
|
|
40
|
+
export interface SupabaseImportSource extends ImportRequestCommon {
|
|
41
|
+
source: 'supabase';
|
|
42
|
+
sourceProjectRef: string;
|
|
43
|
+
sourceConnectionString: string;
|
|
44
|
+
sourceServiceKey: string;
|
|
45
|
+
}
|
|
46
|
+
/** Firebase's project password hash parameters. */
|
|
47
|
+
export interface FirebaseHashParameters {
|
|
48
|
+
base64_signer_key: string;
|
|
49
|
+
base64_salt_separator: string;
|
|
50
|
+
rounds: number;
|
|
51
|
+
mem_cost: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A Firebase export: inline text (Firestore NDJSON + `firebase auth:export`
|
|
55
|
+
* JSON) or a folder written by `writeFirebaseExport` under the control plane's
|
|
56
|
+
* `SCRIBASE_IMPORT_EXPORTS_DIR`.
|
|
57
|
+
*/
|
|
58
|
+
export interface FirebaseImportSource extends ImportRequestCommon {
|
|
59
|
+
source: 'firebase';
|
|
60
|
+
sourceFirebaseProjectId: string;
|
|
61
|
+
sourceExport?: {
|
|
62
|
+
firestore?: string;
|
|
63
|
+
auth?: string;
|
|
64
|
+
};
|
|
65
|
+
sourceExportDir?: string;
|
|
66
|
+
sourceHashConfig?: FirebaseHashParameters;
|
|
67
|
+
}
|
|
68
|
+
/** An InstantDB export: inline `instant-export.json` text or a folder. */
|
|
69
|
+
export interface InstantImportSource extends ImportRequestCommon {
|
|
70
|
+
source: 'instantdb';
|
|
71
|
+
sourceInstantAppId: string;
|
|
72
|
+
sourceExport?: {
|
|
73
|
+
document: string;
|
|
74
|
+
};
|
|
75
|
+
sourceExportDir?: string;
|
|
76
|
+
}
|
|
77
|
+
export type AnyImportSource = SupabaseImportSource | FirebaseImportSource | InstantImportSource;
|
|
78
|
+
/**
|
|
79
|
+
* One table, source versus Scribase, as returned in `verification.tables` of a
|
|
80
|
+
* completed report: the evidence behind the row-count and checksum checks.
|
|
81
|
+
*/
|
|
82
|
+
export interface ImportTableParity {
|
|
83
|
+
table: string;
|
|
84
|
+
sourceRows: number;
|
|
85
|
+
targetRows: number;
|
|
86
|
+
sourceChecksum: string;
|
|
87
|
+
targetChecksum: string;
|
|
88
|
+
rowsMatch: boolean;
|
|
89
|
+
checksumMatch: boolean;
|
|
90
|
+
}
|
|
91
|
+
/** Reads the per-table parity from a report, or `[]` when it has none. */
|
|
92
|
+
export declare function tableParity(report: ImportReport): ImportTableParity[];
|
|
93
|
+
/**
|
|
94
|
+
* `POST /v1/imports` body. Credentials are sent once to run the migration and
|
|
95
|
+
* are never logged or echoed back in the report.
|
|
96
|
+
*
|
|
97
|
+
* The wire model is the generated {@link CreateImportRequest}; this is the
|
|
98
|
+
* client-facing name for it, so the request shape has one definition.
|
|
99
|
+
*/
|
|
100
|
+
export type ImportRequest = CreateImportRequest;
|
|
101
|
+
export type { ImportDestination, ImportFinding, ImportTally, ImportVerification, ImportVerificationCheck, ImportDryRun, ImportReport, ImportCategory, ImportSeverity, ImportCheckStatus, ImportJob, ImportJobError, } from '../types.gen.js';
|
|
102
|
+
/** Options for following a background import to completion. */
|
|
103
|
+
export interface ImportWaitOptions {
|
|
104
|
+
/** Poll interval in milliseconds (default 2000, minimum 250). */
|
|
105
|
+
intervalMs?: number;
|
|
106
|
+
/** Called with every progress snapshot, including the final one. */
|
|
107
|
+
onProgress?: (job: ImportJob) => void;
|
|
108
|
+
signal?: AbortSignal;
|
|
109
|
+
}
|
|
110
|
+
/** Thrown by {@link ImportsResource.wait} when a background import fails. */
|
|
111
|
+
export declare class ImportFailedError extends Error {
|
|
112
|
+
readonly job: ImportJob;
|
|
113
|
+
constructor(job: ImportJob);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Imports: migrate a Supabase project, a Firebase export, or an InstantDB
|
|
117
|
+
* export into a Scribase environment, or dry-run the plan first. Everything
|
|
118
|
+
* hits `POST /v1/imports`. A dry run answers with the plan; a full run starts
|
|
119
|
+
* in the background and answers with an {@link ImportJob} whose progress
|
|
120
|
+
* `GET /v1/imports/{id}` reports. Backs
|
|
121
|
+
* `scribase import supabase --project-ref <ref> [--dry-run]`.
|
|
122
|
+
*/
|
|
123
|
+
export declare class ImportsResource {
|
|
124
|
+
#private;
|
|
125
|
+
constructor(http: HttpTransport);
|
|
126
|
+
/**
|
|
127
|
+
* `POST /v1/imports` with `dryRun: false` — start the migration in the
|
|
128
|
+
* background and return its {@link ImportJob} (use {@link wait} or
|
|
129
|
+
* {@link run} to follow it).
|
|
130
|
+
*/
|
|
131
|
+
create(request: Omit<ImportRequest, 'dryRun'>, options?: {
|
|
132
|
+
signal?: AbortSignal;
|
|
133
|
+
idempotencyKey?: string;
|
|
134
|
+
}): Promise<ImportJob>;
|
|
135
|
+
/**
|
|
136
|
+
* `POST /v1/imports` with `dryRun: true` — plan the move and return the
|
|
137
|
+
* {@link ImportDryRun} without writing anything.
|
|
138
|
+
*/
|
|
139
|
+
dryRun(request: Omit<ImportRequest, 'dryRun'>, options?: {
|
|
140
|
+
signal?: AbortSignal;
|
|
141
|
+
}): Promise<ImportDryRun>;
|
|
142
|
+
/**
|
|
143
|
+
* `POST /v1/imports` for any source — Supabase, Firebase, or InstantDB —
|
|
144
|
+
* started in the background. Returns the {@link ImportJob}.
|
|
145
|
+
*/
|
|
146
|
+
createFrom(request: AnyImportSource, options?: {
|
|
147
|
+
signal?: AbortSignal;
|
|
148
|
+
idempotencyKey?: string;
|
|
149
|
+
}): Promise<ImportJob>;
|
|
150
|
+
/** `POST /v1/imports` for any source with `dryRun: true`. Writes nothing. */
|
|
151
|
+
dryRunFrom(request: AnyImportSource, options?: {
|
|
152
|
+
signal?: AbortSignal;
|
|
153
|
+
}): Promise<ImportDryRun>;
|
|
154
|
+
/**
|
|
155
|
+
* `GET /v1/imports/{importId}` — a background run's status, phase, counts
|
|
156
|
+
* moved so far, findings, errors, and (once finished) its report. Pass the
|
|
157
|
+
* organization to read a run the control plane has since restarted past
|
|
158
|
+
* from the import history.
|
|
159
|
+
*/
|
|
160
|
+
progress(importId: string, options?: {
|
|
161
|
+
organizationId?: PortableIdentifier;
|
|
162
|
+
signal?: AbortSignal;
|
|
163
|
+
}): Promise<ImportJob>;
|
|
164
|
+
/**
|
|
165
|
+
* Polls {@link progress} until the run finishes. Resolves with the final
|
|
166
|
+
* job (its `report` carries the fail-closed `verdict` and, in
|
|
167
|
+
* `verification.tables`, per-table row counts and checksums); rejects with
|
|
168
|
+
* {@link ImportFailedError} when the run failed.
|
|
169
|
+
*/
|
|
170
|
+
wait(importId: string, options?: ImportWaitOptions & {
|
|
171
|
+
organizationId?: PortableIdentifier;
|
|
172
|
+
}): Promise<ImportJob>;
|
|
173
|
+
/**
|
|
174
|
+
* Starts a run for any source and follows it to the end: the one-call form
|
|
175
|
+
* of {@link createFrom} plus {@link wait}. Resolves with the finished report.
|
|
176
|
+
*/
|
|
177
|
+
run(request: AnyImportSource, options?: ImportWaitOptions): Promise<ImportReport>;
|
|
178
|
+
/** `GET /v1/organizations/{org}/imports` — persisted runs, newest first. */
|
|
179
|
+
history(organizationId: PortableIdentifier, params?: ImportHistoryParams): Promise<ImportSummary[]>;
|
|
180
|
+
/** `GET /v1/organizations/{org}/imports/{importId}` — one run in full. */
|
|
181
|
+
report(organizationId: PortableIdentifier, importId: PortableIdentifier): Promise<ImportRecord>;
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../src/resources/imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE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