@fabrika/app 0.9.0-dev.6 → 0.9.0-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/app",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -109,14 +109,14 @@
|
|
|
109
109
|
"test": "bun test --path-ignore-patterns='src/react/**' && bun test --isolate src/react"
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
|
-
"@fabrika/auth": "0.9.0-dev.
|
|
113
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
114
|
-
"@fabrika/db": "0.9.0-dev.
|
|
115
|
-
"@fabrika/email": "0.9.0-dev.
|
|
116
|
-
"@fabrika/jwks": "0.9.0-dev.
|
|
117
|
-
"@fabrika/platform": "0.9.0-dev.
|
|
118
|
-
"@fabrika/platform-node": "0.9.0-dev.
|
|
119
|
-
"@fabrika/proxy-core": "0.9.0-dev.
|
|
112
|
+
"@fabrika/auth": "0.9.0-dev.7",
|
|
113
|
+
"@fabrika/auth-core": "0.9.0-dev.7",
|
|
114
|
+
"@fabrika/db": "0.9.0-dev.7",
|
|
115
|
+
"@fabrika/email": "0.9.0-dev.7",
|
|
116
|
+
"@fabrika/jwks": "0.9.0-dev.7",
|
|
117
|
+
"@fabrika/platform": "0.9.0-dev.7",
|
|
118
|
+
"@fabrika/platform-node": "0.9.0-dev.7",
|
|
119
|
+
"@fabrika/proxy-core": "0.9.0-dev.7",
|
|
120
120
|
"altcha-lib": "2.6.0",
|
|
121
121
|
"jose": "^5.9.0"
|
|
122
122
|
},
|
package/skill/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: fabrika-app
|
|
3
|
-
version: 0.9.0-dev.
|
|
3
|
+
version: 0.9.0-dev.7
|
|
4
4
|
description: >
|
|
5
5
|
How to write and change a Fabrika application: src/vocabulary.ts, db/migrations/, src/db/tables.ts, the
|
|
6
6
|
slices' endpoints.ts with their handlers, fabrika.contract.ts, jobs, files, webhooks, share links, connectors
|
|
@@ -19,20 +19,20 @@ the SPA is added with it.
|
|
|
19
19
|
"test": "bun test --isolate"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fabrika/app": "0.9.0-dev.
|
|
23
|
-
"@fabrika/db": "0.9.0-dev.
|
|
24
|
-
"@fabrika/provider-zerops": "0.9.0-dev.
|
|
25
|
-
"@fabrika/proxy-core": "0.9.0-dev.
|
|
26
|
-
"@fabrika/ui": "0.9.0-dev.
|
|
22
|
+
"@fabrika/app": "0.9.0-dev.7",
|
|
23
|
+
"@fabrika/db": "0.9.0-dev.7",
|
|
24
|
+
"@fabrika/provider-zerops": "0.9.0-dev.7",
|
|
25
|
+
"@fabrika/proxy-core": "0.9.0-dev.7",
|
|
26
|
+
"@fabrika/ui": "0.9.0-dev.7",
|
|
27
27
|
"kysely": "0.29.6",
|
|
28
28
|
"react": "^19.0.0",
|
|
29
29
|
"react-dom": "^19.0.0",
|
|
30
30
|
"zod": "^3.25.76"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@fabrika/check": "0.9.0-dev.
|
|
34
|
-
"@fabrika/cli": "0.9.0-dev.
|
|
35
|
-
"@fabrika/platform": "0.9.0-dev.
|
|
33
|
+
"@fabrika/check": "0.9.0-dev.7",
|
|
34
|
+
"@fabrika/cli": "0.9.0-dev.7",
|
|
35
|
+
"@fabrika/platform": "0.9.0-dev.7",
|
|
36
36
|
"@happy-dom/global-registrator": "^20.11.2",
|
|
37
37
|
"@types/bun": "^1.4.3",
|
|
38
38
|
"@types/react": "^19.0.0",
|
package/src/cloudflare/import.ts
CHANGED
|
@@ -762,9 +762,9 @@ function sameDdl(left: readonly OpsDumpSchemaEntry[], right: readonly OpsDumpSch
|
|
|
762
762
|
}
|
|
763
763
|
|
|
764
764
|
/**
|
|
765
|
-
* The schema `planOpsDump` reads, from the PRAGMAs workerd admits, of every table a dump holds.
|
|
766
|
-
*
|
|
767
|
-
*
|
|
765
|
+
* The schema `planOpsDump` reads, from the PRAGMAs workerd admits, of every table a dump holds. An `INITIALLY DEFERRED`
|
|
766
|
+
* clause is read from the table's SQL outside its quotes and comments, and marks every foreign key of its table; the
|
|
767
|
+
* names a `CHECK` reads come from the same SQL (`checkNamesOf`).
|
|
768
768
|
*/
|
|
769
769
|
export function describeDumpSchema(storage: SqliteStorage): OpsDumpSchema {
|
|
770
770
|
const tables: OpsDumpSchemaTable[] = []
|
|
@@ -781,7 +781,7 @@ export function describeDumpSchema(storage: SqliteStorage): OpsDumpSchema {
|
|
|
781
781
|
name,
|
|
782
782
|
virtual,
|
|
783
783
|
withoutRowid: flag(row['wr']),
|
|
784
|
-
|
|
784
|
+
checkNames: typeof sql === 'string' ? checkNamesOf(sql) : null,
|
|
785
785
|
// A virtual table is refused whatever it holds, and its module may not be loaded to describe it.
|
|
786
786
|
columns: virtual ? [] : describeColumns(storage, name),
|
|
787
787
|
indexes: virtual ? [] : describeIndexes(storage, name),
|
|
@@ -841,6 +841,90 @@ function describeForeignKeys(storage: SqliteStorage, table: string, initiallyDef
|
|
|
841
841
|
})
|
|
842
842
|
}
|
|
843
843
|
|
|
844
|
+
type SqlToken =
|
|
845
|
+
| { readonly kind: 'name'; readonly text: string; readonly quoted: boolean }
|
|
846
|
+
| { readonly kind: 'open' | 'close' | 'other' }
|
|
847
|
+
|
|
848
|
+
const WORD_CHAR = /[A-Za-z0-9_$\u0080-\uffff]/
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* The names the `CHECK` clauses of a table's `sql` read: every word and quoted identifier between a `CHECK` keyword's
|
|
852
|
+
* parentheses, ASCII-lowercase, keywords and numbers included, so it lists at least every column a `CHECK` reads. A
|
|
853
|
+
* string literal and a comment name nothing; a double-quoted string, which SQLite may read as either, counts as a name.
|
|
854
|
+
* `null` when the text does not scan (an unclosed quote, comment or parenthesis), which counts as naming every column.
|
|
855
|
+
*/
|
|
856
|
+
export function checkNamesOf(sql: string): string[] | null {
|
|
857
|
+
const tokens = sqlTokens(sql)
|
|
858
|
+
if (tokens === null) return null
|
|
859
|
+
const names: string[] = []
|
|
860
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
861
|
+
const token = tokens[index]
|
|
862
|
+
if (token?.kind !== 'name' || token.quoted || asciiLower(token.text) !== 'check' || tokens[index + 1]?.kind !== 'open') continue
|
|
863
|
+
let depth = 0
|
|
864
|
+
let end = index + 1
|
|
865
|
+
for (; end < tokens.length; end++) {
|
|
866
|
+
const inner = tokens[end]
|
|
867
|
+
if (inner?.kind === 'open') depth++
|
|
868
|
+
else if (inner?.kind === 'close' && --depth === 0) break
|
|
869
|
+
else if (inner?.kind === 'name') names.push(asciiLower(inner.text))
|
|
870
|
+
}
|
|
871
|
+
if (end === tokens.length) return null
|
|
872
|
+
index = end
|
|
873
|
+
}
|
|
874
|
+
return names
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/** `sql` as words, quoted identifiers and parentheses; string literals, comments and whitespace dropped. */
|
|
878
|
+
function sqlTokens(sql: string): SqlToken[] | null {
|
|
879
|
+
const tokens: SqlToken[] = []
|
|
880
|
+
let index = 0
|
|
881
|
+
while (index < sql.length) {
|
|
882
|
+
const char = sql.charAt(index)
|
|
883
|
+
if (sql.startsWith('--', index)) {
|
|
884
|
+
const end = sql.indexOf('\n', index)
|
|
885
|
+
index = end < 0 ? sql.length : end + 1
|
|
886
|
+
} else if (sql.startsWith('/*', index)) {
|
|
887
|
+
const end = sql.indexOf('*/', index + 2)
|
|
888
|
+
if (end < 0) return null
|
|
889
|
+
index = end + 2
|
|
890
|
+
} else if (char === "'" || char === '"' || char === '`' || char === '[') {
|
|
891
|
+
const close = char === '[' ? ']' : char
|
|
892
|
+
let end = index + 1
|
|
893
|
+
let text = ''
|
|
894
|
+
for (;;) {
|
|
895
|
+
const next = sql.indexOf(close, end)
|
|
896
|
+
if (next < 0) return null
|
|
897
|
+
text += sql.slice(end, next)
|
|
898
|
+
if (close !== ']' && sql.charAt(next + 1) === close) {
|
|
899
|
+
text += close
|
|
900
|
+
end = next + 2
|
|
901
|
+
continue
|
|
902
|
+
}
|
|
903
|
+
end = next + 1
|
|
904
|
+
break
|
|
905
|
+
}
|
|
906
|
+
if (char !== "'") tokens.push({ kind: 'name', text, quoted: true })
|
|
907
|
+
index = end
|
|
908
|
+
} else if (WORD_CHAR.test(char)) {
|
|
909
|
+
let end = index + 1
|
|
910
|
+
while (end < sql.length && WORD_CHAR.test(sql.charAt(end))) end++
|
|
911
|
+
tokens.push({ kind: 'name', text: sql.slice(index, end), quoted: false })
|
|
912
|
+
index = end
|
|
913
|
+
} else {
|
|
914
|
+
if (char === '(') tokens.push({ kind: 'open' })
|
|
915
|
+
else if (char === ')') tokens.push({ kind: 'close' })
|
|
916
|
+
else if (!/\s/.test(char)) tokens.push({ kind: 'other' })
|
|
917
|
+
index++
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return tokens
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/** SQLite compares identifiers case-insensitively in ASCII only. */
|
|
924
|
+
function asciiLower(value: string): string {
|
|
925
|
+
return value.replace(/[A-Z]/g, (letter) => letter.toLowerCase())
|
|
926
|
+
}
|
|
927
|
+
|
|
844
928
|
/** `sql` with its string literals, quoted identifiers and comments blanked, so a keyword search finds only clauses. */
|
|
845
929
|
function unquotedSql(sql: string): string {
|
|
846
930
|
let out = ''
|
|
@@ -44,8 +44,15 @@ export declare function importInProgress(storage: {
|
|
|
44
44
|
*/
|
|
45
45
|
export declare function importStep(target: ImportTarget, barrier: MaintenanceBarrier, step: OpsImportRequest): Promise<Response>;
|
|
46
46
|
/**
|
|
47
|
-
* The schema `planOpsDump` reads, from the PRAGMAs workerd admits, of every table a dump holds.
|
|
48
|
-
*
|
|
49
|
-
*
|
|
47
|
+
* The schema `planOpsDump` reads, from the PRAGMAs workerd admits, of every table a dump holds. An `INITIALLY DEFERRED`
|
|
48
|
+
* clause is read from the table's SQL outside its quotes and comments, and marks every foreign key of its table; the
|
|
49
|
+
* names a `CHECK` reads come from the same SQL (`checkNamesOf`).
|
|
50
50
|
*/
|
|
51
51
|
export declare function describeDumpSchema(storage: SqliteStorage): OpsDumpSchema;
|
|
52
|
+
/**
|
|
53
|
+
* The names the `CHECK` clauses of a table's `sql` read: every word and quoted identifier between a `CHECK` keyword's
|
|
54
|
+
* parentheses, ASCII-lowercase, keywords and numbers included, so it lists at least every column a `CHECK` reads. A
|
|
55
|
+
* string literal and a comment name nothing; a double-quoted string, which SQLite may read as either, counts as a name.
|
|
56
|
+
* `null` when the text does not scan (an unclosed quote, comment or parenthesis), which counts as naming every column.
|
|
57
|
+
*/
|
|
58
|
+
export declare function checkNamesOf(sql: string): string[] | null;
|