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.
Files changed (162) hide show
  1. package/README.md +220 -0
  2. package/dist/cli/credentials.d.ts +35 -0
  3. package/dist/cli/credentials.d.ts.map +1 -0
  4. package/dist/cli/credentials.js +125 -0
  5. package/dist/cli/credentials.js.map +1 -0
  6. package/dist/cli/envfile.d.ts +20 -0
  7. package/dist/cli/envfile.d.ts.map +1 -0
  8. package/dist/cli/envfile.js +86 -0
  9. package/dist/cli/envfile.js.map +1 -0
  10. package/dist/cli/framework.d.ts +45 -0
  11. package/dist/cli/framework.d.ts.map +1 -0
  12. package/dist/cli/framework.js +107 -0
  13. package/dist/cli/framework.js.map +1 -0
  14. package/dist/cli/index.d.ts +8 -0
  15. package/dist/cli/index.d.ts.map +1 -0
  16. package/dist/cli/index.js +239 -0
  17. package/dist/cli/index.js.map +1 -0
  18. package/dist/cli/init.d.ts +118 -0
  19. package/dist/cli/init.d.ts.map +1 -0
  20. package/dist/cli/init.js +455 -0
  21. package/dist/cli/init.js.map +1 -0
  22. package/dist/cli/login.d.ts +104 -0
  23. package/dist/cli/login.d.ts.map +1 -0
  24. package/dist/cli/login.js +306 -0
  25. package/dist/cli/login.js.map +1 -0
  26. package/dist/cli/pow.d.ts +9 -0
  27. package/dist/cli/pow.d.ts.map +1 -0
  28. package/dist/cli/pow.js +31 -0
  29. package/dist/cli/pow.js.map +1 -0
  30. package/dist/cli/vercel.d.ts +92 -0
  31. package/dist/cli/vercel.d.ts.map +1 -0
  32. package/dist/cli/vercel.js +230 -0
  33. package/dist/cli/vercel.js.map +1 -0
  34. package/dist/client.d.ts +137 -0
  35. package/dist/client.d.ts.map +1 -0
  36. package/dist/client.js +311 -0
  37. package/dist/client.js.map +1 -0
  38. package/dist/errors.d.ts +79 -0
  39. package/dist/errors.d.ts.map +1 -0
  40. package/dist/errors.js +139 -0
  41. package/dist/errors.js.map +1 -0
  42. package/dist/evidence.d.ts +78 -0
  43. package/dist/evidence.d.ts.map +1 -0
  44. package/dist/evidence.js +36 -0
  45. package/dist/evidence.js.map +1 -0
  46. package/dist/idempotency.d.ts +24 -0
  47. package/dist/idempotency.d.ts.map +1 -0
  48. package/dist/idempotency.js +59 -0
  49. package/dist/idempotency.js.map +1 -0
  50. package/dist/importers/firebase.d.ts +101 -0
  51. package/dist/importers/firebase.d.ts.map +1 -0
  52. package/dist/importers/firebase.js +251 -0
  53. package/dist/importers/firebase.js.map +1 -0
  54. package/dist/importers/index.d.ts +11 -0
  55. package/dist/importers/index.d.ts.map +1 -0
  56. package/dist/importers/index.js +9 -0
  57. package/dist/importers/index.js.map +1 -0
  58. package/dist/importers/instantdb.d.ts +76 -0
  59. package/dist/importers/instantdb.d.ts.map +1 -0
  60. package/dist/importers/instantdb.js +152 -0
  61. package/dist/importers/instantdb.js.map +1 -0
  62. package/dist/index.d.ts +78 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +53 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/pagination.d.ts +33 -0
  67. package/dist/pagination.d.ts.map +1 -0
  68. package/dist/pagination.js +68 -0
  69. package/dist/pagination.js.map +1 -0
  70. package/dist/resources/account.d.ts +156 -0
  71. package/dist/resources/account.d.ts.map +1 -0
  72. package/dist/resources/account.js +114 -0
  73. package/dist/resources/account.js.map +1 -0
  74. package/dist/resources/audit.d.ts +26 -0
  75. package/dist/resources/audit.d.ts.map +1 -0
  76. package/dist/resources/audit.js +43 -0
  77. package/dist/resources/audit.js.map +1 -0
  78. package/dist/resources/auth.d.ts +149 -0
  79. package/dist/resources/auth.d.ts.map +1 -0
  80. package/dist/resources/auth.js +70 -0
  81. package/dist/resources/auth.js.map +1 -0
  82. package/dist/resources/backups.d.ts +117 -0
  83. package/dist/resources/backups.d.ts.map +1 -0
  84. package/dist/resources/backups.js +92 -0
  85. package/dist/resources/backups.js.map +1 -0
  86. package/dist/resources/branches.d.ts +151 -0
  87. package/dist/resources/branches.d.ts.map +1 -0
  88. package/dist/resources/branches.js +62 -0
  89. package/dist/resources/branches.js.map +1 -0
  90. package/dist/resources/database.d.ts +107 -0
  91. package/dist/resources/database.d.ts.map +1 -0
  92. package/dist/resources/database.js +54 -0
  93. package/dist/resources/database.js.map +1 -0
  94. package/dist/resources/environments.d.ts +106 -0
  95. package/dist/resources/environments.d.ts.map +1 -0
  96. package/dist/resources/environments.js +131 -0
  97. package/dist/resources/environments.js.map +1 -0
  98. package/dist/resources/export.d.ts +101 -0
  99. package/dist/resources/export.d.ts.map +1 -0
  100. package/dist/resources/export.js +89 -0
  101. package/dist/resources/export.js.map +1 -0
  102. package/dist/resources/functions.d.ts +75 -0
  103. package/dist/resources/functions.d.ts.map +1 -0
  104. package/dist/resources/functions.js +58 -0
  105. package/dist/resources/functions.js.map +1 -0
  106. package/dist/resources/imports.d.ts +183 -0
  107. package/dist/resources/imports.d.ts.map +1 -0
  108. package/dist/resources/imports.js +168 -0
  109. package/dist/resources/imports.js.map +1 -0
  110. package/dist/resources/insights.d.ts +50 -0
  111. package/dist/resources/insights.d.ts.map +1 -0
  112. package/dist/resources/insights.js +21 -0
  113. package/dist/resources/insights.js.map +1 -0
  114. package/dist/resources/metrics.d.ts +61 -0
  115. package/dist/resources/metrics.d.ts.map +1 -0
  116. package/dist/resources/metrics.js +23 -0
  117. package/dist/resources/metrics.js.map +1 -0
  118. package/dist/resources/migrations.d.ts +24 -0
  119. package/dist/resources/migrations.d.ts.map +1 -0
  120. package/dist/resources/migrations.js +29 -0
  121. package/dist/resources/migrations.js.map +1 -0
  122. package/dist/resources/operations.d.ts +37 -0
  123. package/dist/resources/operations.d.ts.map +1 -0
  124. package/dist/resources/operations.js +81 -0
  125. package/dist/resources/operations.js.map +1 -0
  126. package/dist/resources/organizations.d.ts +171 -0
  127. package/dist/resources/organizations.d.ts.map +1 -0
  128. package/dist/resources/organizations.js +180 -0
  129. package/dist/resources/organizations.js.map +1 -0
  130. package/dist/resources/previews.d.ts +49 -0
  131. package/dist/resources/previews.d.ts.map +1 -0
  132. package/dist/resources/previews.js +62 -0
  133. package/dist/resources/previews.js.map +1 -0
  134. package/dist/resources/projects.d.ts +73 -0
  135. package/dist/resources/projects.d.ts.map +1 -0
  136. package/dist/resources/projects.js +84 -0
  137. package/dist/resources/projects.js.map +1 -0
  138. package/dist/resources/queues.d.ts +100 -0
  139. package/dist/resources/queues.d.ts.map +1 -0
  140. package/dist/resources/queues.js +77 -0
  141. package/dist/resources/queues.js.map +1 -0
  142. package/dist/resources/realtime.d.ts +37 -0
  143. package/dist/resources/realtime.d.ts.map +1 -0
  144. package/dist/resources/realtime.js +23 -0
  145. package/dist/resources/realtime.js.map +1 -0
  146. package/dist/resources/restores.d.ts +67 -0
  147. package/dist/resources/restores.d.ts.map +1 -0
  148. package/dist/resources/restores.js +90 -0
  149. package/dist/resources/restores.js.map +1 -0
  150. package/dist/resources/storage.d.ts +50 -0
  151. package/dist/resources/storage.d.ts.map +1 -0
  152. package/dist/resources/storage.js +38 -0
  153. package/dist/resources/storage.js.map +1 -0
  154. package/dist/resources/usage.d.ts +85 -0
  155. package/dist/resources/usage.d.ts.map +1 -0
  156. package/dist/resources/usage.js +37 -0
  157. package/dist/resources/usage.js.map +1 -0
  158. package/dist/types.gen.d.ts +473 -0
  159. package/dist/types.gen.d.ts.map +1 -0
  160. package/dist/types.gen.js +8 -0
  161. package/dist/types.gen.js.map +1 -0
  162. package/package.json +53 -0
@@ -0,0 +1,151 @@
1
+ import type { HttpTransport } from '../client.js';
2
+ import type { PortableIdentifier } from '../types.gen.js';
3
+ /** The two portable identifiers that address one project. */
4
+ export interface ProjectRef {
5
+ organizationId: PortableIdentifier;
6
+ projectId: PortableIdentifier;
7
+ }
8
+ /** One recorded branch, as returned by {@link BranchesResource.list}. */
9
+ export interface BranchRecord {
10
+ /** The branch environment identifier. */
11
+ environment_id: string;
12
+ /** Epoch seconds the branch was recorded. */
13
+ created_at: number;
14
+ /** The parent environment, when this branch forked from one. */
15
+ base?: string;
16
+ /** The linked pull request reference, when one is attached. */
17
+ pull_request?: string;
18
+ /** The rendered preview URL, when one is set. */
19
+ preview_url?: string;
20
+ }
21
+ /** The recorded branches for a project. */
22
+ export interface BranchList {
23
+ branches: BranchRecord[];
24
+ }
25
+ /** Body for recording a branch's lineage. */
26
+ export interface RegisterBranchRequest {
27
+ /** The branch environment to record. */
28
+ environment_id: string;
29
+ /** The parent environment. Omit for a root branch (forks from an empty base). */
30
+ base_environment_id?: string;
31
+ }
32
+ /** Result of {@link BranchesResource.register}. */
33
+ export interface RegisteredBranch {
34
+ /** Always true on success. */
35
+ registered: boolean;
36
+ /** The branch environment that was recorded. */
37
+ environment_id: string;
38
+ /** How many schema objects were captured as the fork base. */
39
+ fork_base_objects: number;
40
+ }
41
+ /** A schema object as it appears in a diff: identity and fingerprint only. */
42
+ export interface SchemaObject {
43
+ /** Object kind (`view`, `materialized_view`, `index`, `function`, `trigger`). */
44
+ kind: string;
45
+ /** Schema the object belongs to. */
46
+ schema: string;
47
+ /** Object name. */
48
+ name: string;
49
+ /** `md5` fingerprint of the object's canonical definition. */
50
+ fingerprint: string;
51
+ }
52
+ /** A changed object in a diff: its state on each side. */
53
+ export interface ChangedObject {
54
+ before: SchemaObject;
55
+ after: SchemaObject;
56
+ }
57
+ /** Body for a two-way schema diff. */
58
+ export interface BranchDiffRequest {
59
+ /** The base branch environment. */
60
+ base: string;
61
+ /** The head branch environment. */
62
+ head: string;
63
+ }
64
+ /** A two-way schema diff between two branches. */
65
+ export interface SchemaDiff {
66
+ /** Objects present on head but not base. */
67
+ added: SchemaObject[];
68
+ /** Objects present on base but not head. */
69
+ removed: SchemaObject[];
70
+ /** Objects present on both whose definition differs. */
71
+ changed: ChangedObject[];
72
+ }
73
+ /** Body for a three-way merge of `head` into `base`. */
74
+ export interface BranchMergeRequest {
75
+ /** The base branch the merge applies to. */
76
+ base: string;
77
+ /** The head branch being merged in. */
78
+ head: string;
79
+ /** Apply a conflicting plan anyway. A clean plan applies without this. */
80
+ force?: boolean;
81
+ }
82
+ /** One planned change in a merge. */
83
+ export interface MergeChange {
84
+ /** The qualified object the change applies to. */
85
+ object: string;
86
+ /** The merge action (for example `apply` or `drop`). */
87
+ action: string;
88
+ }
89
+ /** One conflict in a merge plan. */
90
+ export interface MergeConflict {
91
+ /** The qualified object in conflict. */
92
+ object: string;
93
+ /** The conflict kind. */
94
+ kind: string;
95
+ }
96
+ /** The outcome of a three-way merge. */
97
+ export interface MergeResult {
98
+ /** Whether the plan's statements were applied to the base branch. */
99
+ applied: boolean;
100
+ /** Whether the plan was conflict-free. */
101
+ clean: boolean;
102
+ changes: MergeChange[];
103
+ conflicts: MergeConflict[];
104
+ }
105
+ /** The pull-request provider a branch is linked to. */
106
+ export type PullRequestProvider = 'github' | 'gitlab' | 'bitbucket' | 'generic';
107
+ /** Body for linking a branch to a pull request. */
108
+ export interface LinkPullRequestRequest {
109
+ provider: PullRequestProvider;
110
+ /** The repository the pull request lives in. */
111
+ repository: string;
112
+ /** The pull-request number. */
113
+ number: number;
114
+ /**
115
+ * Optional preview-URL template. `{organization}`, `{project}`, and
116
+ * `{environment}` are substituted.
117
+ */
118
+ url_template?: string;
119
+ }
120
+ /** The result of linking a branch to a pull request. */
121
+ export interface LinkedPullRequest {
122
+ /** The branch environment that was linked. */
123
+ branch: string;
124
+ /** The canonical pull-request reference. */
125
+ pull_request: string;
126
+ /** The rendered preview URL, when a template was provided. */
127
+ preview_url?: string;
128
+ }
129
+ /**
130
+ * Branches — copy-on-write database branches for a project. `register` records a
131
+ * branch's lineage (the fork base a later `merge` needs); `diff` is a two-way
132
+ * schema diff between any two branches; `merge` is a three-way merge; `linkPr`
133
+ * attaches a branch to a pull request and renders its preview URL.
134
+ */
135
+ export declare class BranchesResource {
136
+ #private;
137
+ constructor(http: HttpTransport);
138
+ /** `GET …/projects/{project}/branches` — the recorded branches. */
139
+ list(ref: ProjectRef): Promise<BranchRecord[]>;
140
+ /** `POST …/branches` — record a branch's lineage and fork base. */
141
+ register(ref: ProjectRef, request: RegisterBranchRequest): Promise<RegisteredBranch>;
142
+ /** `POST …/branches/diff` — a two-way schema diff between two branches. */
143
+ diff(ref: ProjectRef, request: BranchDiffRequest): Promise<SchemaDiff>;
144
+ /** `POST …/branches/merge` — a three-way merge of `head` into `base`. */
145
+ merge(ref: ProjectRef, request: BranchMergeRequest): Promise<MergeResult>;
146
+ /** `POST …/branches/{branch}/pr` — link a branch to a pull request. */
147
+ linkPullRequest(ref: ProjectRef, branch: string, request: LinkPullRequestRequest): Promise<LinkedPullRequest>;
148
+ }
149
+ /** Build the canonical branches path, encoding each portable identifier. */
150
+ export declare function branchesPath(ref: ProjectRef): string;
151
+ //# sourceMappingURL=branches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branches.d.ts","sourceRoot":"","sources":["../../src/resources/branches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,6DAA6D;AAC7D,MAAM,WAAW,UAAU;IACzB,cAAc,EAAE,kBAAkB,CAAC;IACnC,SAAS,EAAE,kBAAkB,CAAC;CAC/B;AAED,yEAAyE;AACzE,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,cAAc,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,2CAA2C;AAC3C,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED,6CAA6C;AAC7C,MAAM,WAAW,qBAAqB;IACpC,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAC;I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,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAS/E,uEAAuE;IACjE,eAAe,CACnB,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,iBAAiB,CAAC;CAQ9B;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAKpD"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Branches — copy-on-write database branches for a project. `register` records a
3
+ * branch's lineage (the fork base a later `merge` needs); `diff` is a two-way
4
+ * schema diff between any two branches; `merge` is a three-way merge; `linkPr`
5
+ * attaches a branch to a pull request and renders its preview URL.
6
+ */
7
+ export class BranchesResource {
8
+ #http;
9
+ constructor(http) {
10
+ this.#http = http;
11
+ }
12
+ /** `GET …/projects/{project}/branches` — the recorded branches. */
13
+ async list(ref) {
14
+ const result = await this.#http.send({
15
+ method: 'GET',
16
+ path: branchesPath(ref),
17
+ });
18
+ return result.data.branches;
19
+ }
20
+ /** `POST …/branches` — record a branch's lineage and fork base. */
21
+ async register(ref, request) {
22
+ const result = await this.#http.send({
23
+ method: 'POST',
24
+ path: branchesPath(ref),
25
+ body: request,
26
+ });
27
+ return result.data;
28
+ }
29
+ /** `POST …/branches/diff` — a two-way schema diff between two branches. */
30
+ async diff(ref, request) {
31
+ const result = await this.#http.send({
32
+ method: 'POST',
33
+ path: `${branchesPath(ref)}/diff`,
34
+ body: request,
35
+ });
36
+ return result.data;
37
+ }
38
+ /** `POST …/branches/merge` — a three-way merge of `head` into `base`. */
39
+ async merge(ref, request) {
40
+ const result = await this.#http.send({
41
+ method: 'POST',
42
+ path: `${branchesPath(ref)}/merge`,
43
+ body: request,
44
+ });
45
+ return result.data;
46
+ }
47
+ /** `POST …/branches/{branch}/pr` — link a branch to a pull request. */
48
+ async linkPullRequest(ref, branch, request) {
49
+ const result = await this.#http.send({
50
+ method: 'POST',
51
+ path: `${branchesPath(ref)}/${encodeURIComponent(branch)}/pr`,
52
+ body: request,
53
+ });
54
+ return result.data;
55
+ }
56
+ }
57
+ /** Build the canonical branches path, encoding each portable identifier. */
58
+ export function branchesPath(ref) {
59
+ return (`/v1/organizations/${encodeURIComponent(ref.organizationId)}` +
60
+ `/projects/${encodeURIComponent(ref.projectId)}/branches`);
61
+ }
62
+ //# sourceMappingURL=branches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branches.js","sourceRoot":"","sources":["../../src/resources/branches.ts"],"names":[],"mappings":"AAiJA;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAClB,KAAK,CAAgB;IAE9B,YAAY,IAAmB;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,mEAAmE;IACnE,KAAK,CAAC,IAAI,CAAC,GAAe;QACxB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAa;YAC/C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC;SACxB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,mEAAmE;IACnE,KAAK,CAAC,QAAQ,CAAC,GAAe,EAAE,OAA8B;QAC5D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAmB;YACrD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC;YACvB,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,2EAA2E;IAC3E,KAAK,CAAC,IAAI,CAAC,GAAe,EAAE,OAA0B;QACpD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAa;YAC/C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO;YACjC,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,yEAAyE;IACzE,KAAK,CAAC,KAAK,CAAC,GAAe,EAAE,OAA2B;QACtD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAc;YAChD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,GAAG,YAAY,CAAC,GAAG,CAAC,QAAQ;YAClC,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,uEAAuE;IACvE,KAAK,CAAC,eAAe,CACnB,GAAe,EACf,MAAc,EACd,OAA+B;QAE/B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAoB;YACtD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,KAAK;YAC7D,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,UAAU,YAAY,CAAC,GAAe;IAC1C,OAAO,CACL,qBAAqB,kBAAkB,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE;QAC7D,aAAa,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAC1D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,107 @@
1
+ import type { HttpTransport } from '../client.js';
2
+ import type { EnvironmentRef } from './environments.js';
3
+ /** One column of an introspected table. Optional fields are omitted, never null. */
4
+ export interface DatabaseColumn {
5
+ name: string;
6
+ /** SQL type, e.g. `uuid`, `text`, `timestamptz`. */
7
+ type: string;
8
+ nullable: boolean;
9
+ unique: boolean;
10
+ /** `table(column)` this column references, when it is a foreign key. */
11
+ references?: string;
12
+ /** SQL default expression. */
13
+ default?: string;
14
+ }
15
+ /** The access rule derived from the table's RLS policies. */
16
+ export type TableAccess = {
17
+ rule: 'owner';
18
+ column: string;
19
+ } | {
20
+ rule: 'public_read';
21
+ owner_column: string;
22
+ } | {
23
+ rule: 'tenant';
24
+ column: string;
25
+ membership_model: string;
26
+ membership_tenant_column: string;
27
+ membership_user_column: string;
28
+ } | {
29
+ rule: 'internal';
30
+ };
31
+ export interface DatabaseTable {
32
+ name: string;
33
+ access: TableAccess;
34
+ /** True when an anonymous (anon-key) client can read rows. */
35
+ anonymous_readable: boolean;
36
+ columns: DatabaseColumn[];
37
+ }
38
+ /** A fidelity or security note produced while introspecting. */
39
+ export interface DatabaseNote {
40
+ model: string;
41
+ kind: string;
42
+ detail: string;
43
+ /** The introspected model cannot represent this faithfully. */
44
+ loses_information: boolean;
45
+ /** The note is a security finding about the database (e.g. RLS disabled). */
46
+ security_finding: boolean;
47
+ column?: string;
48
+ }
49
+ /** Response of {@link DatabaseResource.tables}. */
50
+ export interface DatabaseTables {
51
+ tables: DatabaseTable[];
52
+ notes: DatabaseNote[];
53
+ /** True when no note loses information. */
54
+ faithful: boolean;
55
+ }
56
+ export interface QueryOptions {
57
+ /** Row cap; the server clamps it to its own maximum. */
58
+ limit?: number;
59
+ }
60
+ /** Rows from a `SELECT`/`WITH` statement, capped at `applied_limit`. */
61
+ export interface QueryRows<Row = Record<string, unknown>> {
62
+ kind: 'rows';
63
+ /** Total rows the statement produced. */
64
+ row_count: number;
65
+ /** Rows actually returned (≤ `applied_limit`). */
66
+ returned: number;
67
+ applied_limit: number;
68
+ truncated: boolean;
69
+ rows: Row[];
70
+ }
71
+ /** The text plan of an `EXPLAIN` (never `ANALYZE`). */
72
+ export interface QueryExplain {
73
+ kind: 'explain';
74
+ plan: string[];
75
+ }
76
+ export type QueryResult<Row = Record<string, unknown>> = QueryRows<Row> | QueryExplain;
77
+ export interface GenerateTypesOptions {
78
+ /** Schemas to include, in order. Defaults to `['public']`. */
79
+ schemas?: readonly string[];
80
+ }
81
+ /** Response of {@link DatabaseResource.generateTypes}. */
82
+ export interface EnvironmentTypes {
83
+ /** A TypeScript module exporting `Database`, `Json`, `Tables<>`, `Enums<>` and `Constants`. */
84
+ types: string;
85
+ schemas: string[];
86
+ }
87
+ /**
88
+ * Database — introspection and a bounded, read-only SQL console for one
89
+ * environment. `query` accepts a single `SELECT`, `WITH`, or `EXPLAIN`; writes
90
+ * and DDL are rejected before execution and again by the database's read-only
91
+ * transaction. Schema changes go through `client.migrations`, never here.
92
+ */
93
+ export declare class DatabaseResource {
94
+ #private;
95
+ constructor(http: HttpTransport);
96
+ /** `GET …/environments/{env}/database/tables` — public tables and access rules. */
97
+ tables(ref: EnvironmentRef): Promise<DatabaseTables>;
98
+ /**
99
+ * `GET …/environments/{env}/types` — supabase-js `Database` types for the
100
+ * environment, identical to `scribase gen types`. Write `result.types` to a
101
+ * `.ts` file and pass `Database` to `createClient<Database>()`.
102
+ */
103
+ generateTypes(ref: EnvironmentRef, options?: GenerateTypesOptions): Promise<EnvironmentTypes>;
104
+ /** `POST …/environments/{env}/database/query` — run one read-only statement. */
105
+ query<Row = Record<string, unknown>>(ref: EnvironmentRef, sql: string, options?: QueryOptions): Promise<QueryResult<Row>>;
106
+ }
107
+ //# sourceMappingURL=database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/resources/database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,oFAAoF;AACpF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM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Database — introspection and a bounded, read-only SQL console for one
4
+ * environment. `query` accepts a single `SELECT`, `WITH`, or `EXPLAIN`; writes
5
+ * and DDL are rejected before execution and again by the database's read-only
6
+ * transaction. Schema changes go through `client.migrations`, never here.
7
+ */
8
+ export class DatabaseResource {
9
+ #http;
10
+ constructor(http) {
11
+ this.#http = http;
12
+ }
13
+ /** `GET …/environments/{env}/database/tables` — public tables and access rules. */
14
+ async tables(ref) {
15
+ const result = await this.#http.send({
16
+ method: 'GET',
17
+ path: `${environmentPath(ref)}/database/tables`,
18
+ });
19
+ return result.data;
20
+ }
21
+ /**
22
+ * `GET …/environments/{env}/types` — supabase-js `Database` types for the
23
+ * environment, identical to `scribase gen types`. Write `result.types` to a
24
+ * `.ts` file and pass `Database` to `createClient<Database>()`.
25
+ */
26
+ async generateTypes(ref, options) {
27
+ const schemas = options?.schemas ?? ['public'];
28
+ if (schemas.length === 0 || schemas.some((schema) => schema.trim().length === 0 || schema.includes(','))) {
29
+ throw new RangeError('schemas must be non-empty names without commas');
30
+ }
31
+ const result = await this.#http.send({
32
+ method: 'GET',
33
+ path: `${environmentPath(ref)}/types`,
34
+ query: { schema: schemas.join(',') },
35
+ });
36
+ return result.data;
37
+ }
38
+ /** `POST …/environments/{env}/database/query` — run one read-only statement. */
39
+ async query(ref, sql, options) {
40
+ if (sql.trim().length === 0) {
41
+ throw new RangeError('query must not be empty');
42
+ }
43
+ const result = await this.#http.send({
44
+ method: 'POST',
45
+ path: `${environmentPath(ref)}/database/query`,
46
+ body: {
47
+ query: sql,
48
+ ...(options?.limit !== undefined ? { limit: options.limit } : {}),
49
+ },
50
+ });
51
+ return result.data;
52
+ }
53
+ }
54
+ //# sourceMappingURL=database.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/resources/database.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AA8FpD;;;;;GAKG;AACH,MAAM,OAAO,gBAAg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,CAAC,yBAAyB,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAmB;YACrD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,GAAG,eAAe,CAAC,GAAG,CAAC,iBAAiB;YAC9C,IAAI,EAAE;gBACJ,KAAK,EAAE,GAAG;gBACV,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAClE;SACF,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;CACF"}
@@ -0,0 +1,106 @@
1
+ import type { AcceptedOperation, HttpTransport } from '../client.js';
2
+ import type { CreateEnvironmentRequest, Environment, EnvironmentApiKeys, PortableIdentifier } from '../types.gen.js';
3
+ /** The three portable identifiers that address one environment. */
4
+ export interface EnvironmentRef {
5
+ organizationId: PortableIdentifier;
6
+ projectId: PortableIdentifier;
7
+ environmentId: PortableIdentifier;
8
+ }
9
+ export interface ListEnvironmentsParams {
10
+ organizationId: PortableIdentifier;
11
+ /** Narrow to a single project. */
12
+ projectId?: PortableIdentifier;
13
+ /** 1..200, default 100. */
14
+ limit?: number;
15
+ }
16
+ /** Options common to mutating environment calls. */
17
+ export interface MutationOptions {
18
+ /** Explicit idempotency key; one is minted when omitted. */
19
+ idempotencyKey?: string;
20
+ signal?: AbortSignal;
21
+ }
22
+ /** Result of {@link EnvironmentsResource.renew}. */
23
+ export interface RenewedEnvironment {
24
+ organization_id: PortableIdentifier;
25
+ project_id: PortableIdentifier;
26
+ environment_id: PortableIdentifier;
27
+ ttl_hours: number;
28
+ last_activity_epoch_seconds: number;
29
+ expires_at_epoch_seconds: number;
30
+ }
31
+ /** Result of {@link EnvironmentsResource.connection}. Server-side only. */
32
+ export interface EnvironmentConnection {
33
+ connection_uri: string;
34
+ }
35
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
36
+ /** One service log line. */
37
+ export interface LogEntry {
38
+ timestamp_epoch_ms: number;
39
+ level: LogLevel;
40
+ /** Emitting service, e.g. `postgres`, `auth`, `storage`. */
41
+ service: string;
42
+ message: string;
43
+ request_id?: string;
44
+ }
45
+ /** A page of log lines; pass `next_cursor` back as `cursor` for older lines. */
46
+ export interface LogPage {
47
+ items: LogEntry[];
48
+ next_cursor?: string;
49
+ }
50
+ export interface ListLogsParams {
51
+ /** 1..1000, default 200. */
52
+ limit?: number;
53
+ level?: LogLevel;
54
+ /** Opaque cursor from a previous page's `next_cursor`. */
55
+ cursor?: string;
56
+ }
57
+ /**
58
+ * Environments — the reconciled, provisioned instances of a project spec. Reads
59
+ * return the full desired/observed state; every mutation returns an
60
+ * {@link AcceptedOperation} to poll via `client.operations.wait`.
61
+ */
62
+ export declare class EnvironmentsResource {
63
+ #private;
64
+ constructor(http: HttpTransport);
65
+ /** `GET /v1/environments` — the fleet view across one organization. */
66
+ list(params: ListEnvironmentsParams): Promise<Environment[]>;
67
+ /** `POST /v1/environments` — provision an environment (async). */
68
+ create(body: CreateEnvironmentRequest, options?: MutationOptions): Promise<AcceptedOperation>;
69
+ /** `GET /v1/organizations/{org}/projects/{project}/environments/{env}`. */
70
+ get(ref: EnvironmentRef): Promise<Environment>;
71
+ /** `DELETE …/environments/{env}` — tear down (async). */
72
+ delete(ref: EnvironmentRef, options?: MutationOptions): Promise<AcceptedOperation>;
73
+ /** `POST …/environments/{env}/suspend` — stop compute, keep state (async). */
74
+ suspend(ref: EnvironmentRef, options?: MutationOptions): Promise<AcceptedOperation>;
75
+ /** `POST …/environments/{env}/resume` — bring a suspended env back (async). */
76
+ resume(ref: EnvironmentRef, options?: MutationOptions): Promise<AcceptedOperation>;
77
+ /**
78
+ * `POST …/environments/{env}/renew` — extend an auto-expiring environment's
79
+ * lifetime to `ttlHours` from now. Returns the new expiry window.
80
+ */
81
+ renew(ref: EnvironmentRef, ttlHours: number, options?: {
82
+ signal?: AbortSignal;
83
+ }): Promise<RenewedEnvironment>;
84
+ /**
85
+ * `GET …/environments/{env}/connection` — the tenant Postgres connection URI.
86
+ * SERVER-SIDE ONLY: the DSN carries a database credential and must never be
87
+ * sent to a browser or logged.
88
+ */
89
+ connection(ref: EnvironmentRef): Promise<EnvironmentConnection>;
90
+ /**
91
+ * `GET …/environments/{env}/api-keys` — the client keys an app needs: the API
92
+ * URL, the anon JWT and `sb_publishable_` key (safe to ship in an app), and,
93
+ * for members above viewer, the service_role JWT and `sb_secret_` key.
94
+ * The last two bypass row-level security: keep them server-side.
95
+ * `revealJwtSecret` (owners and admins) also returns the JWT signing secret,
96
+ * for servers that verify session tokens themselves.
97
+ */
98
+ apiKeys(ref: EnvironmentRef, options?: {
99
+ revealJwtSecret?: boolean;
100
+ }): Promise<EnvironmentApiKeys>;
101
+ /** `GET …/environments/{env}/logs` — most-recent service log lines, newest first. */
102
+ logs(ref: EnvironmentRef, params?: ListLogsParams): Promise<LogPage>;
103
+ }
104
+ /** Build the canonical environment path, encoding each portable identifier. */
105
+ export declare function environmentPath(ref: EnvironmentRef): string;
106
+ //# sourceMappingURL=environments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../../src/resources/environments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAErE,OAAO,KAAK,EACV,wBAAwB,EACxB,WAAW,EACX,kBAAkB,EAGlB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAEzB,mEAAmE;AACnE,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,kBAAkB,CAAC;IACnC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,aAAa,EAAE,kBAAkB,CAAC;CACnC;AAED,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,kBAAkB,CAAC;IACnC,kCAAkC;IAClC,SAAS,CAAC,EAAE,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empotency.js';
2
+ /**
3
+ * Environments — the reconciled, provisioned instances of a project spec. Reads
4
+ * return the full desired/observed state; every mutation returns an
5
+ * {@link AcceptedOperation} to poll via `client.operations.wait`.
6
+ */
7
+ export class EnvironmentsResource {
8
+ #http;
9
+ constructor(http) {
10
+ this.#http = http;
11
+ }
12
+ /** `GET /v1/environments` — the fleet view across one organization. */
13
+ async list(params) {
14
+ const result = await this.#http.send({
15
+ method: 'GET',
16
+ path: '/v1/environments',
17
+ query: {
18
+ organization_id: params.organizationId,
19
+ project_id: params.projectId,
20
+ limit: params.limit,
21
+ },
22
+ });
23
+ return result.data.environments;
24
+ }
25
+ /** `POST /v1/environments` — provision an environment (async). */
26
+ async create(body, options) {
27
+ const result = await this.#http.send({
28
+ method: 'POST',
29
+ path: '/v1/environments',
30
+ body,
31
+ idempotencyKey: resolveIdempotencyKey(options?.idempotencyKey),
32
+ ...(options?.signal ? { signal: options.signal } : {}),
33
+ });
34
+ return { operation: result.data, idempotencyReplayed: result.idempotencyReplayed };
35
+ }
36
+ /** `GET /v1/organizations/{org}/projects/{project}/environments/{env}`. */
37
+ async get(ref) {
38
+ const result = await this.#http.send({
39
+ method: 'GET',
40
+ path: environmentPath(ref),
41
+ });
42
+ return result.data;
43
+ }
44
+ /** `DELETE …/environments/{env}` — tear down (async). */
45
+ async delete(ref, options) {
46
+ const result = await this.#http.send({
47
+ method: 'DELETE',
48
+ path: environmentPath(ref),
49
+ idempotencyKey: resolveIdempotencyKey(options?.idempotencyKey),
50
+ ...(options?.signal ? { signal: options.signal } : {}),
51
+ });
52
+ return { operation: result.data, idempotencyReplayed: result.idempotencyReplayed };
53
+ }
54
+ /** `POST …/environments/{env}/suspend` — stop compute, keep state (async). */
55
+ async suspend(ref, options) {
56
+ return this.#transition(ref, 'suspend', options);
57
+ }
58
+ /** `POST …/environments/{env}/resume` — bring a suspended env back (async). */
59
+ async resume(ref, options) {
60
+ return this.#transition(ref, 'resume', options);
61
+ }
62
+ /**
63
+ * `POST …/environments/{env}/renew` — extend an auto-expiring environment's
64
+ * lifetime to `ttlHours` from now. Returns the new expiry window.
65
+ */
66
+ async renew(ref, ttlHours, options) {
67
+ if (!Number.isInteger(ttlHours) || ttlHours < 1 || ttlHours > 65_535) {
68
+ throw new RangeError(`ttlHours must be a positive integer, got ${ttlHours}`);
69
+ }
70
+ const result = await this.#http.send({
71
+ method: 'POST',
72
+ path: `${environmentPath(ref)}/renew`,
73
+ body: { ttl_hours: ttlHours },
74
+ ...(options?.signal ? { signal: options.signal } : {}),
75
+ });
76
+ return result.data;
77
+ }
78
+ /**
79
+ * `GET …/environments/{env}/connection` — the tenant Postgres connection URI.
80
+ * SERVER-SIDE ONLY: the DSN carries a database credential and must never be
81
+ * sent to a browser or logged.
82
+ */
83
+ async connection(ref) {
84
+ const result = await this.#http.send({
85
+ method: 'GET',
86
+ path: `${environmentPath(ref)}/connection`,
87
+ });
88
+ return result.data;
89
+ }
90
+ /**
91
+ * `GET …/environments/{env}/api-keys` — the client keys an app needs: the API
92
+ * URL, the anon JWT and `sb_publishable_` key (safe to ship in an app), and,
93
+ * for members above viewer, the service_role JWT and `sb_secret_` key.
94
+ * The last two bypass row-level security: keep them server-side.
95
+ * `revealJwtSecret` (owners and admins) also returns the JWT signing secret,
96
+ * for servers that verify session tokens themselves.
97
+ */
98
+ async apiKeys(ref, options) {
99
+ const result = await this.#http.send({
100
+ method: 'GET',
101
+ path: `${environmentPath(ref)}/api-keys`,
102
+ ...(options?.revealJwtSecret ? { query: { reveal: 'jwt_secret' } } : {}),
103
+ });
104
+ return result.data;
105
+ }
106
+ /** `GET …/environments/{env}/logs` — most-recent service log lines, newest first. */
107
+ async logs(ref, params) {
108
+ const result = await this.#http.send({
109
+ method: 'GET',
110
+ path: `${environmentPath(ref)}/logs`,
111
+ query: { limit: params?.limit, level: params?.level, from: params?.cursor },
112
+ });
113
+ return result.data;
114
+ }
115
+ async #transition(ref, action, options) {
116
+ const result = await this.#http.send({
117
+ method: 'POST',
118
+ path: `${environmentPath(ref)}/${action}`,
119
+ idempotencyKey: resolveIdempotencyKey(options?.idempotencyKey),
120
+ ...(options?.signal ? { signal: options.signal } : {}),
121
+ });
122
+ return { operation: result.data, idempotencyReplayed: result.idempotencyReplayed };
123
+ }
124
+ }
125
+ /** Build the canonical environment path, encoding each portable identifier. */
126
+ export function environmentPath(ref) {
127
+ return (`/v1/organizations/${encodeURIComponent(ref.organizationId)}` +
128
+ `/projects/${encodeURIComponent(ref.projectId)}` +
129
+ `/environments/${encodeURIComponent(ref.environmentId)}`);
130
+ }
131
+ //# sourceMappingURL=environments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environments.js","sourceRoot":"","sources":["../../src/resources/environments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAyE1D;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IACtB,KAAK,CAAgB;IAE9B,YAAY,IAAmB;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,uEAAuE;IACvE,KAAK,CAAC,IAAI,CAAC,MAA8B;QACvC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAA2B;YAC7D,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,kBAAkB;YACxB,KAAK,EAAE;gBACL,eAAe,EAAE,MAAM,CAAC,cAAc;gBACtC,UAAU,EAAE,MAAM,CAAC,SAAS;gBAC5B,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB;SACF,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;IAClC,CAAC;IAED,kEAAkE;IAClE,KAAK,CAAC,MAAM,CACV,IAA8B,EAC9B,OAAyB;QAEzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY;YAC9C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,kBAAkB;YACxB,IAAI;YACJ,cAAc,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