@zveltio/sdk 2.0.8 → 3.0.0-beta.100

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 (157) hide show
  1. package/README.md +17 -4
  2. package/dist/build/index.d.ts +77 -0
  3. package/dist/build/index.d.ts.map +1 -0
  4. package/dist/build/index.js +157 -0
  5. package/dist/client.d.ts +103 -7
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +129 -28
  8. package/dist/core.d.ts.map +1 -1
  9. package/dist/core.js +21 -3
  10. package/dist/crdt.d.ts.map +1 -1
  11. package/dist/crdt.js +11 -2
  12. package/dist/ddl/index.d.ts +173 -0
  13. package/dist/ddl/index.d.ts.map +1 -0
  14. package/dist/ddl/index.js +33 -0
  15. package/dist/errors.d.ts +58 -0
  16. package/dist/errors.d.ts.map +1 -0
  17. package/dist/errors.js +124 -0
  18. package/dist/extension/action-refusal.d.ts +27 -0
  19. package/dist/extension/action-refusal.d.ts.map +1 -0
  20. package/dist/extension/action-refusal.js +29 -0
  21. package/dist/extension/capabilities.d.ts +71 -0
  22. package/dist/extension/capabilities.d.ts.map +1 -0
  23. package/dist/extension/capabilities.js +79 -0
  24. package/dist/extension/dates.d.ts +7 -0
  25. package/dist/extension/dates.d.ts.map +1 -0
  26. package/dist/extension/dates.js +14 -0
  27. package/dist/extension/index.d.ts +1570 -10
  28. package/dist/extension/index.d.ts.map +1 -1
  29. package/dist/extension/index.js +17 -1
  30. package/dist/extension/jsonb.d.ts +62 -0
  31. package/dist/extension/jsonb.d.ts.map +1 -0
  32. package/dist/extension/jsonb.js +64 -0
  33. package/dist/extension/multipart.d.ts +58 -0
  34. package/dist/extension/multipart.d.ts.map +1 -0
  35. package/dist/extension/multipart.js +61 -0
  36. package/dist/extension/numeric.d.ts +94 -0
  37. package/dist/extension/numeric.d.ts.map +1 -0
  38. package/dist/extension/numeric.js +162 -0
  39. package/dist/extension/permission-gate.d.ts +52 -0
  40. package/dist/extension/permission-gate.d.ts.map +1 -0
  41. package/dist/extension/permission-gate.js +125 -0
  42. package/dist/extension/reserved-paths.d.ts +10 -0
  43. package/dist/extension/reserved-paths.d.ts.map +1 -0
  44. package/dist/extension/reserved-paths.js +23 -0
  45. package/dist/index.d.ts +4 -2
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +1 -0
  48. package/dist/local-store.d.ts +14 -1
  49. package/dist/local-store.d.ts.map +1 -1
  50. package/dist/local-store.js +93 -16
  51. package/dist/offline/index.d.ts +75 -0
  52. package/dist/offline/index.d.ts.map +1 -0
  53. package/dist/offline/index.js +251 -0
  54. package/dist/publish/index.d.ts +94 -0
  55. package/dist/publish/index.d.ts.map +1 -0
  56. package/dist/publish/index.js +153 -0
  57. package/dist/realtime.d.ts +25 -1
  58. package/dist/realtime.d.ts.map +1 -1
  59. package/dist/realtime.js +53 -5
  60. package/dist/rpc/index.d.ts +68 -0
  61. package/dist/rpc/index.d.ts.map +1 -0
  62. package/dist/rpc/index.js +63 -0
  63. package/dist/schema-codegen.d.ts +84 -0
  64. package/dist/schema-codegen.d.ts.map +1 -0
  65. package/dist/schema-codegen.js +503 -0
  66. package/dist/schema-watcher.d.ts +10 -2
  67. package/dist/schema-watcher.d.ts.map +1 -1
  68. package/dist/schema-watcher.js +26 -13
  69. package/dist/studio/index.d.ts +85 -0
  70. package/dist/studio/index.d.ts.map +1 -0
  71. package/dist/studio/index.js +183 -0
  72. package/dist/studio/slot-owner-registry.d.ts +13 -0
  73. package/dist/studio/slot-owner-registry.d.ts.map +1 -0
  74. package/dist/studio/slot-owner-registry.js +21 -0
  75. package/dist/svelte.d.ts +1 -1
  76. package/dist/svelte.d.ts.map +1 -1
  77. package/dist/svelte.js +4 -2
  78. package/dist/sync-manager.d.ts +49 -4
  79. package/dist/sync-manager.d.ts.map +1 -1
  80. package/dist/sync-manager.js +175 -24
  81. package/dist/testing/index.d.ts +121 -0
  82. package/dist/testing/index.d.ts.map +1 -0
  83. package/dist/testing/index.js +305 -0
  84. package/dist/testing/with-test-db.d.ts +119 -0
  85. package/dist/testing/with-test-db.d.ts.map +1 -0
  86. package/dist/testing/with-test-db.js +320 -0
  87. package/dist/tests/action-refusal.test.d.ts +2 -0
  88. package/dist/tests/action-refusal.test.d.ts.map +1 -0
  89. package/dist/tests/action-refusal.test.js +13 -0
  90. package/dist/tests/client.test.d.ts +2 -0
  91. package/dist/tests/client.test.d.ts.map +1 -0
  92. package/dist/tests/client.test.js +164 -0
  93. package/dist/tests/crdt-orset.test.d.ts +2 -0
  94. package/dist/tests/crdt-orset.test.d.ts.map +1 -0
  95. package/dist/tests/crdt-orset.test.js +23 -0
  96. package/dist/tests/local-store.test.js +44 -0
  97. package/dist/tests/migration-parse.test.d.ts +2 -0
  98. package/dist/tests/migration-parse.test.d.ts.map +1 -0
  99. package/dist/tests/migration-parse.test.js +17 -0
  100. package/dist/tests/multipart.test.d.ts +2 -0
  101. package/dist/tests/multipart.test.d.ts.map +1 -0
  102. package/dist/tests/multipart.test.js +37 -0
  103. package/dist/tests/offline-provider-crdt.test.d.ts +2 -0
  104. package/dist/tests/offline-provider-crdt.test.d.ts.map +1 -0
  105. package/dist/tests/offline-provider-crdt.test.js +206 -0
  106. package/dist/tests/realtime.test.d.ts +2 -0
  107. package/dist/tests/realtime.test.d.ts.map +1 -0
  108. package/dist/tests/realtime.test.js +220 -0
  109. package/dist/tests/reserved-paths.test.d.ts +2 -0
  110. package/dist/tests/reserved-paths.test.d.ts.map +1 -0
  111. package/dist/tests/reserved-paths.test.js +21 -0
  112. package/dist/tests/sync-manager.test.d.ts +2 -0
  113. package/dist/tests/sync-manager.test.d.ts.map +1 -0
  114. package/dist/tests/sync-manager.test.js +123 -0
  115. package/dist/tests/today-in.test.d.ts +2 -0
  116. package/dist/tests/today-in.test.d.ts.map +1 -0
  117. package/dist/tests/today-in.test.js +14 -0
  118. package/dist/tests/validate-manifest-actions.test.d.ts +2 -0
  119. package/dist/tests/validate-manifest-actions.test.d.ts.map +1 -0
  120. package/dist/tests/validate-manifest-actions.test.js +82 -0
  121. package/dist/tests/validate-manifest-dependencies.test.d.ts +2 -0
  122. package/dist/tests/validate-manifest-dependencies.test.d.ts.map +1 -0
  123. package/dist/tests/validate-manifest-dependencies.test.js +27 -0
  124. package/dist/tests/validate-manifest-forward-credentials.test.d.ts +2 -0
  125. package/dist/tests/validate-manifest-forward-credentials.test.d.ts.map +1 -0
  126. package/dist/tests/validate-manifest-forward-credentials.test.js +35 -0
  127. package/dist/tests/validate-sdui-data-endpoints.test.d.ts +2 -0
  128. package/dist/tests/validate-sdui-data-endpoints.test.d.ts.map +1 -0
  129. package/dist/tests/validate-sdui-data-endpoints.test.js +41 -0
  130. package/dist/tests/with-test-db.test.d.ts +2 -0
  131. package/dist/tests/with-test-db.test.d.ts.map +1 -0
  132. package/dist/tests/with-test-db.test.js +57 -0
  133. package/dist/types/index.d.ts.map +1 -1
  134. package/dist/utils.d.ts.map +1 -1
  135. package/dist/utils.js +3 -1
  136. package/dist/validate/index.d.ts +148 -0
  137. package/dist/validate/index.d.ts.map +1 -0
  138. package/dist/validate/index.js +887 -0
  139. package/dist/validate/migration-parse.d.ts +22 -0
  140. package/dist/validate/migration-parse.d.ts.map +1 -0
  141. package/dist/validate/migration-parse.js +11 -0
  142. package/dist/validate/shared-message-keys.d.ts +16 -0
  143. package/dist/validate/shared-message-keys.d.ts.map +1 -0
  144. package/dist/validate/shared-message-keys.js +227 -0
  145. package/package.json +56 -4
  146. package/dist/client/Auth.d.ts +0 -19
  147. package/dist/client/Auth.d.ts.map +0 -1
  148. package/dist/client/Auth.js +0 -45
  149. package/dist/client/QueryBuilder.d.ts +0 -17
  150. package/dist/client/QueryBuilder.d.ts.map +0 -1
  151. package/dist/client/QueryBuilder.js +0 -76
  152. package/dist/client/RealtimeClient.d.ts +0 -22
  153. package/dist/client/RealtimeClient.d.ts.map +0 -1
  154. package/dist/client/RealtimeClient.js +0 -96
  155. package/dist/client/ZveltioClient.d.ts +0 -20
  156. package/dist/client/ZveltioClient.d.ts.map +0 -1
  157. package/dist/client/ZveltioClient.js +0 -78
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Parse a single SQL migration file into its UP and DOWN sections.
3
+ *
4
+ * The DOWN section starts at the first line that is exactly `-- DOWN` (case
5
+ * insensitive, surrounding spaces allowed). Everything before that marker is
6
+ * UP; everything after the marker line is DOWN. If the marker is absent, the
7
+ * whole file is UP.
8
+ *
9
+ * Mirror of `packages/engine/src/lib/extensions/extension-utils.ts:parseMigrationSql`
10
+ * — kept in the SDK so validators and tooling can call it without depending
11
+ * on engine internals. The two must agree on the marker: the engine was moved
12
+ * to the anchored `\s*$` form and this copy kept `\b`, so a comment such as
13
+ * `-- DOWN: manual rollback required` ended UP here and not there —
14
+ * `withTestDb` applied half an extension's schema while the engine applied all
15
+ * of it, and the validator saw a DOWN section the engine did not.
16
+ */
17
+ export interface ParsedMigration {
18
+ up: string;
19
+ down: string | null;
20
+ }
21
+ export declare function parseMigrationSql(raw: string): ParsedMigration;
22
+ //# sourceMappingURL=migration-parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-parse.d.ts","sourceRoot":"","sources":["../../src/validate/migration-parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAU9D"}
@@ -0,0 +1,11 @@
1
+ export function parseMigrationSql(raw) {
2
+ const downIdx = raw.search(/^--\s*DOWN\s*$/im);
3
+ if (downIdx < 0) {
4
+ return { up: raw.trim(), down: null };
5
+ }
6
+ const up = raw.slice(0, downIdx).trim();
7
+ const downSection = raw.slice(downIdx);
8
+ const firstNewline = downSection.indexOf('\n');
9
+ const downBody = firstNewline >= 0 ? downSection.slice(firstNewline + 1).trim() : '';
10
+ return { up, down: downBody.length > 0 ? downBody : null };
11
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * GENERATED — do not edit. Run `bun run scripts/sync-shared-message-keys.ts`.
3
+ *
4
+ * The subset of the Studio's core message catalogue that extensions may use
5
+ * in SDUI schemas without shipping the key themselves: the generic vocabulary
6
+ * (`common.*`) plus the shared extension helpers (`ext.*`).
7
+ *
8
+ * An extension that needs anything else must ship it in its own
9
+ * `studio/messages/{locale}.json` — otherwise it renders correctly only on a
10
+ * host whose core catalogue happens to know about it, which is not a property
11
+ * an installable extension should depend on.
12
+ *
13
+ * Source: packages/studio/messages/core/en.json (211 keys)
14
+ */
15
+ export declare const SHARED_MESSAGE_KEYS: ReadonlySet<string>;
16
+ //# sourceMappingURL=shared-message-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-message-keys.d.ts","sourceRoot":"","sources":["../../src/validate/shared-message-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAoNlD,CAAC"}
@@ -0,0 +1,227 @@
1
+ /**
2
+ * GENERATED — do not edit. Run `bun run scripts/sync-shared-message-keys.ts`.
3
+ *
4
+ * The subset of the Studio's core message catalogue that extensions may use
5
+ * in SDUI schemas without shipping the key themselves: the generic vocabulary
6
+ * (`common.*`) plus the shared extension helpers (`ext.*`).
7
+ *
8
+ * An extension that needs anything else must ship it in its own
9
+ * `studio/messages/{locale}.json` — otherwise it renders correctly only on a
10
+ * host whose core catalogue happens to know about it, which is not a property
11
+ * an installable extension should depend on.
12
+ *
13
+ * Source: packages/studio/messages/core/en.json (211 keys)
14
+ */
15
+ export const SHARED_MESSAGE_KEYS = new Set([
16
+ 'common.accessRestricted',
17
+ 'common.actions',
18
+ 'common.add',
19
+ 'common.added',
20
+ 'common.aiStudio',
21
+ 'common.approve',
22
+ 'common.assign',
23
+ 'common.bulkActions',
24
+ 'common.cancel',
25
+ 'common.cancelEdit',
26
+ 'common.clear',
27
+ 'common.clearSelection',
28
+ 'common.close',
29
+ 'common.col.account',
30
+ 'common.col.active',
31
+ 'common.col.address',
32
+ 'common.col.amount',
33
+ 'common.col.balance',
34
+ 'common.col.bank',
35
+ 'common.col.bcc',
36
+ 'common.col.category',
37
+ 'common.col.cc',
38
+ 'common.col.channel',
39
+ 'common.col.client',
40
+ 'common.col.code',
41
+ 'common.col.collection',
42
+ 'common.col.company',
43
+ 'common.col.created',
44
+ 'common.col.credit',
45
+ 'common.col.currency',
46
+ 'common.col.date',
47
+ 'common.col.days',
48
+ 'common.col.debit',
49
+ 'common.col.department',
50
+ 'common.col.description',
51
+ 'common.col.docNumber',
52
+ 'common.col.dueDate',
53
+ 'common.col.duration',
54
+ 'common.col.email',
55
+ 'common.col.employee',
56
+ 'common.col.enabled',
57
+ 'common.col.end',
58
+ 'common.col.event',
59
+ 'common.col.field',
60
+ 'common.col.file',
61
+ 'common.col.from',
62
+ 'common.col.hireDate',
63
+ 'common.col.host',
64
+ 'common.col.iban',
65
+ 'common.col.index',
66
+ 'common.col.key',
67
+ 'common.col.label',
68
+ 'common.col.leaveType',
69
+ 'common.col.locale',
70
+ 'common.col.message',
71
+ 'common.col.method',
72
+ 'common.col.model',
73
+ 'common.col.name',
74
+ 'common.col.notes',
75
+ 'common.col.number',
76
+ 'common.col.paid',
77
+ 'common.col.parent',
78
+ 'common.col.password',
79
+ 'common.col.path',
80
+ 'common.col.phone',
81
+ 'common.col.port',
82
+ 'common.col.position',
83
+ 'common.col.price',
84
+ 'common.col.priority',
85
+ 'common.col.product',
86
+ 'common.col.project',
87
+ 'common.col.provider',
88
+ 'common.col.quantity',
89
+ 'common.col.reason',
90
+ 'common.col.recipient',
91
+ 'common.col.records',
92
+ 'common.col.required',
93
+ 'common.col.resource',
94
+ 'common.col.role',
95
+ 'common.col.sku',
96
+ 'common.col.slug',
97
+ 'common.col.start',
98
+ 'common.col.status',
99
+ 'common.col.subject',
100
+ 'common.col.taxId',
101
+ 'common.col.template',
102
+ 'common.col.ticket',
103
+ 'common.col.time',
104
+ 'common.col.title',
105
+ 'common.col.to',
106
+ 'common.col.total',
107
+ 'common.col.type',
108
+ 'common.col.unique',
109
+ 'common.col.unit',
110
+ 'common.col.user',
111
+ 'common.col.username',
112
+ 'common.col.validUntil',
113
+ 'common.col.value',
114
+ 'common.col.vat',
115
+ 'common.col.vendor',
116
+ 'common.col.version',
117
+ 'common.col.warehouse',
118
+ 'common.col.year',
119
+ 'common.collectionRequired',
120
+ 'common.confirm',
121
+ 'common.copied',
122
+ 'common.copy',
123
+ 'common.copyShort',
124
+ 'common.create',
125
+ 'common.delete',
126
+ 'common.deleteCount',
127
+ 'common.deleteFailed',
128
+ 'common.discard',
129
+ 'common.dismiss',
130
+ 'common.dismissNotification',
131
+ 'common.done',
132
+ 'common.download',
133
+ 'common.edit',
134
+ 'common.emptyDash',
135
+ 'common.failed',
136
+ 'common.fields',
137
+ 'common.filter.admin',
138
+ 'common.filter.all',
139
+ 'common.filter.allStatuses',
140
+ 'common.filter.auth',
141
+ 'common.filter.data',
142
+ 'common.format',
143
+ 'common.generate',
144
+ 'common.loadFailed',
145
+ 'common.loading',
146
+ 'common.logout',
147
+ 'common.manage',
148
+ 'common.mergeFailed',
149
+ 'common.nameRequired',
150
+ 'common.new',
151
+ 'common.next',
152
+ 'common.no',
153
+ 'common.noResults',
154
+ 'common.notFound',
155
+ 'common.op.delete',
156
+ 'common.op.insert',
157
+ 'common.op.update',
158
+ 'common.open',
159
+ 'common.optional',
160
+ 'common.optionalParen',
161
+ 'common.other',
162
+ 'common.pageOf',
163
+ 'common.post',
164
+ 'common.prev',
165
+ 'common.publish',
166
+ 'common.rangeOf',
167
+ 'common.refresh',
168
+ 'common.reject',
169
+ 'common.remove',
170
+ 'common.rename',
171
+ 'common.reorder',
172
+ 'common.required',
173
+ 'common.resetFailed',
174
+ 'common.retry',
175
+ 'common.revoke',
176
+ 'common.save',
177
+ 'common.saveFailed',
178
+ 'common.saved',
179
+ 'common.saving',
180
+ 'common.search',
181
+ 'common.selectCollection',
182
+ 'common.selectPlaceholder',
183
+ 'common.selected',
184
+ 'common.send',
185
+ 'common.somethingWrong',
186
+ 'common.status.approved',
187
+ 'common.status.cancelled',
188
+ 'common.status.draft',
189
+ 'common.status.pending',
190
+ 'common.status.reimbursed',
191
+ 'common.status.rejected',
192
+ 'common.status.submitted',
193
+ 'common.submit',
194
+ 'common.sync',
195
+ 'common.testConnection',
196
+ 'common.typeToSearch',
197
+ 'common.undo',
198
+ 'common.unexpectedError',
199
+ 'common.unknownError',
200
+ 'common.upload',
201
+ 'common.uploadFailed',
202
+ 'common.uploading',
203
+ 'common.verifyingPermissions',
204
+ 'common.view',
205
+ 'common.viewAll',
206
+ 'common.yes',
207
+ 'ext.approved',
208
+ 'ext.confirm.deleteForm',
209
+ 'ext.confirm.deleteNamed',
210
+ 'ext.confirm.removeSearchIndex',
211
+ 'ext.confirmDelete',
212
+ 'ext.copied',
213
+ 'ext.copyFailed',
214
+ 'ext.created',
215
+ 'ext.deleted',
216
+ 'ext.errorPrefix',
217
+ 'ext.linkCopied',
218
+ 'ext.loadFailed',
219
+ 'ext.rejected',
220
+ 'ext.reveal.copy',
221
+ 'ext.reveal.note',
222
+ 'ext.reveal.title',
223
+ 'ext.saveFailed',
224
+ 'ext.saved',
225
+ 'ext.sent',
226
+ 'ext.submitted',
227
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zveltio/sdk",
3
- "version": "2.0.8",
3
+ "version": "3.0.0-beta.100",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,6 +12,42 @@
12
12
  "./extension": {
13
13
  "types": "./dist/extension/index.d.ts",
14
14
  "import": "./dist/extension/index.js"
15
+ },
16
+ "./codegen": {
17
+ "types": "./dist/schema-codegen.d.ts",
18
+ "import": "./dist/schema-codegen.js"
19
+ },
20
+ "./validate": {
21
+ "types": "./dist/validate/index.d.ts",
22
+ "import": "./dist/validate/index.js"
23
+ },
24
+ "./testing": {
25
+ "types": "./dist/testing/index.d.ts",
26
+ "import": "./dist/testing/index.js"
27
+ },
28
+ "./publish": {
29
+ "types": "./dist/publish/index.d.ts",
30
+ "import": "./dist/publish/index.js"
31
+ },
32
+ "./build": {
33
+ "types": "./dist/build/index.d.ts",
34
+ "import": "./dist/build/index.js"
35
+ },
36
+ "./studio": {
37
+ "types": "./dist/studio/index.d.ts",
38
+ "import": "./dist/studio/index.js"
39
+ },
40
+ "./ddl": {
41
+ "types": "./dist/ddl/index.d.ts",
42
+ "import": "./dist/ddl/index.js"
43
+ },
44
+ "./rpc": {
45
+ "types": "./dist/rpc/index.d.ts",
46
+ "import": "./dist/rpc/index.js"
47
+ },
48
+ "./offline": {
49
+ "types": "./dist/offline/index.d.ts",
50
+ "import": "./dist/offline/index.js"
15
51
  }
16
52
  },
17
53
  "files": [
@@ -25,12 +61,28 @@
25
61
  "test": "bun test --preload ./src/tests/setup.ts"
26
62
  },
27
63
  "dependencies": {
28
- "idb": "^8.0.0"
64
+ "idb": "^8.0.3"
29
65
  },
30
66
  "devDependencies": {
67
+ "@testcontainers/postgresql": "^11.14.0",
68
+ "@types/pg": "^8.23.1",
31
69
  "fake-indexeddb": "^6.2.5",
32
- "hono": "^4.12.5",
33
- "typescript": "^5.4.0"
70
+ "hono": "^4.13.8",
71
+ "kysely": "^0.29.7",
72
+ "pg": "^8.23.1",
73
+ "typescript": "^6.0.3"
74
+ },
75
+ "peerDependencies": {
76
+ "@testcontainers/postgresql": "^11.0.0",
77
+ "pg": "^8.13.0"
78
+ },
79
+ "peerDependenciesMeta": {
80
+ "@testcontainers/postgresql": {
81
+ "optional": true
82
+ },
83
+ "pg": {
84
+ "optional": true
85
+ }
34
86
  },
35
87
  "repository": {
36
88
  "type": "git",
@@ -1,19 +0,0 @@
1
- import type { ZveltioConfig } from '../types/index.js';
2
- export declare class Auth {
3
- private config;
4
- constructor(config: ZveltioConfig);
5
- signIn(email: string, password: string): Promise<{
6
- user: any;
7
- session: any;
8
- }>;
9
- signUp(name: string, email: string, password: string): Promise<{
10
- user: any;
11
- }>;
12
- signOut(): Promise<void>;
13
- getSession(): Promise<{
14
- user: any;
15
- session: any;
16
- } | null>;
17
- signInWithOAuth(provider: 'google' | 'github' | 'microsoft'): void;
18
- }
19
- //# sourceMappingURL=Auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../../src/client/Auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,qBAAa,IAAI;IACf,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,aAAa;IAI3B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,GAAG,CAAC;QAAC,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC;IAW7E,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE,CAAC;IAW7E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAOxB,UAAU,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,GAAG,CAAC;QAAC,OAAO,EAAE,GAAG,CAAA;KAAE,GAAG,IAAI,CAAC;IAQ/D,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,IAAI;CAGnE"}
@@ -1,45 +0,0 @@
1
- export class Auth {
2
- config;
3
- constructor(config) {
4
- this.config = config;
5
- }
6
- async signIn(email, password) {
7
- const res = await fetch(`${this.config.baseUrl}/api/auth/sign-in/email`, {
8
- method: 'POST',
9
- credentials: 'include',
10
- headers: { 'Content-Type': 'application/json' },
11
- body: JSON.stringify({ email, password }),
12
- });
13
- if (!res.ok)
14
- throw new Error((await res.json()).message || 'Sign in failed');
15
- return res.json();
16
- }
17
- async signUp(name, email, password) {
18
- const res = await fetch(`${this.config.baseUrl}/api/auth/sign-up/email`, {
19
- method: 'POST',
20
- credentials: 'include',
21
- headers: { 'Content-Type': 'application/json' },
22
- body: JSON.stringify({ name, email, password }),
23
- });
24
- if (!res.ok)
25
- throw new Error((await res.json()).message || 'Sign up failed');
26
- return res.json();
27
- }
28
- async signOut() {
29
- await fetch(`${this.config.baseUrl}/api/auth/sign-out`, {
30
- method: 'POST',
31
- credentials: 'include',
32
- });
33
- }
34
- async getSession() {
35
- const res = await fetch(`${this.config.baseUrl}/api/me`, { credentials: 'include' });
36
- if (!res.ok)
37
- return null;
38
- const data = await res.json();
39
- return { user: data.user, session: {} };
40
- }
41
- // OAuth redirect
42
- signInWithOAuth(provider) {
43
- window.location.href = `${this.config.baseUrl}/api/auth/sign-in/${provider}`;
44
- }
45
- }
@@ -1,17 +0,0 @@
1
- import type { ZveltioConfig, QueryOptions, QueryResponse } from '../types/index.js';
2
- export declare class QueryBuilder {
3
- private _collection;
4
- private _config;
5
- private _filters;
6
- private _options;
7
- constructor(collection: string, config: ZveltioConfig);
8
- where(field: string, value: any): this;
9
- where(field: string, op: string, value: any): this;
10
- page(n: number): this;
11
- limit(n: number): this;
12
- sortBy(field: string, order?: 'asc' | 'desc'): this;
13
- search(q: string): this;
14
- query<T = any>(overrideOptions?: QueryOptions): Promise<QueryResponse<T>>;
15
- [Symbol.asyncIterator]<T = any>(): AsyncGenerator<T[]>;
16
- }
17
- //# sourceMappingURL=QueryBuilder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryBuilder.d.ts","sourceRoot":"","sources":["../../src/client/QueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEpF,qBAAa,YAAY;IACvB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,QAAQ,CAAoB;gBAExB,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa;IAMrD,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IACtC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAWlD,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IACrB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAGtB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,KAAK,GAAG,MAAc,GAAG,IAAI;IAO1D,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAGjB,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,eAAe,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAiCxE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC;CAY9D"}
@@ -1,76 +0,0 @@
1
- export class QueryBuilder {
2
- _collection;
3
- _config;
4
- _filters = {};
5
- _options = {};
6
- constructor(collection, config) {
7
- this._collection = collection;
8
- this._config = config;
9
- }
10
- where(field, opOrValue, value) {
11
- if (value === undefined) {
12
- this._filters[field] = opOrValue;
13
- }
14
- else {
15
- this._filters[field] = { [opOrValue]: value };
16
- }
17
- return this;
18
- }
19
- // Pagination
20
- page(n) { this._options.page = n; return this; }
21
- limit(n) { this._options.limit = n; return this; }
22
- // Sorting
23
- sortBy(field, order = 'asc') {
24
- this._options.sort = field;
25
- this._options.order = order;
26
- return this;
27
- }
28
- // Search
29
- search(q) { this._options.search = q; return this; }
30
- // Execute
31
- async query(overrideOptions) {
32
- const opts = { ...this._options, ...overrideOptions };
33
- const params = new URLSearchParams();
34
- if (opts.page)
35
- params.set('page', String(opts.page));
36
- if (opts.limit)
37
- params.set('limit', String(opts.limit));
38
- if (opts.sort)
39
- params.set('sort', opts.sort);
40
- if (opts.order)
41
- params.set('order', opts.order);
42
- if (opts.search)
43
- params.set('search', opts.search);
44
- if (Object.keys(this._filters).length > 0) {
45
- params.set('filter', JSON.stringify(this._filters));
46
- }
47
- const qs = params.toString();
48
- const url = `/api/data/${this._collection}${qs ? '?' + qs : ''}`;
49
- const headers = { 'Content-Type': 'application/json' };
50
- if (this._config.apiKey)
51
- headers['X-API-Key'] = this._config.apiKey;
52
- const res = await fetch(`${this._config.baseUrl}${url}`, {
53
- credentials: 'include',
54
- headers,
55
- });
56
- if (!res.ok) {
57
- const err = await res.json().catch(() => ({ error: res.statusText }));
58
- throw new Error(err.error || `Query failed: ${res.status}`);
59
- }
60
- return res.json();
61
- }
62
- // Async iterable — allows `for await (const page of query)`
63
- async *[Symbol.asyncIterator]() {
64
- let currentPage = this._options.page || 1;
65
- const pageSize = this._options.limit || 20;
66
- while (true) {
67
- const result = await this.page(currentPage).limit(pageSize).query();
68
- if (result.records.length === 0)
69
- break;
70
- yield result.records;
71
- if (currentPage >= result.pagination.pages)
72
- break;
73
- currentPage++;
74
- }
75
- }
76
- }
@@ -1,22 +0,0 @@
1
- import type { RealtimeMessage } from '../types/index.js';
2
- type EventCallback = (message: RealtimeMessage) => void;
3
- type StatusCallback = (status: 'connecting' | 'connected' | 'disconnected') => void;
4
- export declare class RealtimeClient {
5
- private ws;
6
- private baseUrl;
7
- private subscriptions;
8
- private statusCallbacks;
9
- private reconnectDelay;
10
- private maxReconnectDelay;
11
- private shouldReconnect;
12
- constructor(baseUrl: string);
13
- connect(): void;
14
- disconnect(): void;
15
- subscribe(collection: string, event: string | '*', callback: EventCallback): () => void;
16
- onStatusChange(callback: StatusCallback): () => void;
17
- private sendSubscribe;
18
- private sendUnsubscribe;
19
- private notifyStatus;
20
- }
21
- export {};
22
- //# sourceMappingURL=RealtimeClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RealtimeClient.d.ts","sourceRoot":"","sources":["../../src/client/RealtimeClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,KAAK,aAAa,GAAG,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;AACxD,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,GAAG,cAAc,KAAK,IAAI,CAAC;AAEpF,qBAAa,cAAc;IACzB,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAyC;IAC9D,OAAO,CAAC,eAAe,CAA6B;IACpD,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,eAAe,CAAQ;gBAEnB,OAAO,EAAE,MAAM;IAI3B,OAAO,IAAI,IAAI;IA4Cf,UAAU,IAAI,IAAI;IAQlB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI;IAwBvF,cAAc,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,IAAI;IAKpD,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,YAAY;CAGrB"}
@@ -1,96 +0,0 @@
1
- export class RealtimeClient {
2
- ws = null;
3
- baseUrl;
4
- subscriptions = new Map();
5
- statusCallbacks = new Set();
6
- reconnectDelay = 1000;
7
- maxReconnectDelay = 30000;
8
- shouldReconnect = true;
9
- constructor(baseUrl) {
10
- this.baseUrl = baseUrl;
11
- }
12
- connect() {
13
- if (this.ws?.readyState === WebSocket.OPEN)
14
- return;
15
- const wsUrl = this.baseUrl.replace(/^http/, 'ws') + '/api/ws';
16
- this.ws = new WebSocket(wsUrl);
17
- this.notifyStatus('connecting');
18
- this.ws.onopen = () => {
19
- this.reconnectDelay = 1000;
20
- this.notifyStatus('connected');
21
- // Re-subscribe all active subscriptions
22
- for (const channel of this.subscriptions.keys()) {
23
- this.sendSubscribe(channel);
24
- }
25
- };
26
- this.ws.onmessage = (event) => {
27
- try {
28
- const message = JSON.parse(event.data);
29
- const key = `${message.collection}:${message.event}`;
30
- const wildcard = `${message.collection}:*`;
31
- const allWildcard = `*:*`;
32
- for (const [sub, callbacks] of this.subscriptions) {
33
- if (sub === key || sub === wildcard || sub === allWildcard) {
34
- callbacks.forEach((cb) => cb(message));
35
- }
36
- }
37
- }
38
- catch { /* ignore invalid messages */ }
39
- };
40
- this.ws.onclose = () => {
41
- this.notifyStatus('disconnected');
42
- if (this.shouldReconnect) {
43
- setTimeout(() => this.connect(), this.reconnectDelay);
44
- this.reconnectDelay = Math.min(this.reconnectDelay * 2, this.maxReconnectDelay);
45
- }
46
- };
47
- this.ws.onerror = () => {
48
- this.ws?.close();
49
- };
50
- }
51
- disconnect() {
52
- this.shouldReconnect = false;
53
- this.ws?.close();
54
- this.ws = null;
55
- }
56
- // Subscribe to events on a collection
57
- // pattern examples: 'products:insert', 'products:*', '*:*'
58
- subscribe(collection, event, callback) {
59
- const key = `${collection}:${event}`;
60
- if (!this.subscriptions.has(key)) {
61
- this.subscriptions.set(key, new Set());
62
- }
63
- this.subscriptions.get(key).add(callback);
64
- if (this.ws?.readyState === WebSocket.OPEN) {
65
- this.sendSubscribe(key);
66
- }
67
- else {
68
- this.connect();
69
- }
70
- // Return unsubscribe function
71
- return () => {
72
- this.subscriptions.get(key)?.delete(callback);
73
- if (this.subscriptions.get(key)?.size === 0) {
74
- this.subscriptions.delete(key);
75
- this.sendUnsubscribe(key);
76
- }
77
- };
78
- }
79
- onStatusChange(callback) {
80
- this.statusCallbacks.add(callback);
81
- return () => this.statusCallbacks.delete(callback);
82
- }
83
- sendSubscribe(channel) {
84
- if (this.ws?.readyState === WebSocket.OPEN) {
85
- this.ws.send(JSON.stringify({ type: 'subscribe', channel }));
86
- }
87
- }
88
- sendUnsubscribe(channel) {
89
- if (this.ws?.readyState === WebSocket.OPEN) {
90
- this.ws.send(JSON.stringify({ type: 'unsubscribe', channel }));
91
- }
92
- }
93
- notifyStatus(status) {
94
- this.statusCallbacks.forEach((cb) => cb(status));
95
- }
96
- }