@marktiderman/genesis-cli 1.19.0 → 1.21.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 +98 -1
- package/dist/cli.js +682 -74
- package/dist/cli.js.map +1 -1
- package/dist/doctor.d.ts +1 -1
- package/dist/doctor.js +270 -8
- package/dist/doctor.js.map +1 -1
- package/dist/eslint.cjs +99 -0
- package/dist/eslint.cjs.map +1 -0
- package/dist/eslint.d.cts +68 -0
- package/dist/eslint.d.ts +68 -0
- package/dist/eslint.js +72 -0
- package/dist/eslint.js.map +1 -0
- package/dist/genesis-catalog.json +86 -14
- package/dist/index.js +278 -16
- package/dist/index.js.map +1 -1
- package/dist/starter/README.md +17 -5
- package/dist/starter/__tests__/components/setup.ts +11 -0
- package/dist/starter/__tests__/starter.test.ts +19 -0
- package/dist/starter/eslint.config.js +8 -1
- package/dist/starter/nativewind-env.d.ts +1 -0
- package/dist/starter/package.json +5 -3
- package/dist/starter/src/lib/app.ts +13 -5
- package/dist/starter/src/lib/define-starter.ts +1 -1
- package/dist/starter/src/lib/devtools-overlay.ts +3 -4
- package/dist/starter/src/lib/native-modules.ts +5 -1
- package/dist/starter/src/lib/offline.ts +14 -0
- package/dist/starter/supabase/migrations/20261024000750_support_default_tenant.sql +18 -0
- package/dist/starter/supabase/migrations/20261024000800_genesis_support_tickets.sql +800 -0
- package/dist/starter/supabase/migrations/20261025000070_starter_tenancy.sql +26 -0
- package/dist/starter/supabase/migrations/20261025000080_genesis_chat_tenants.sql +716 -0
- package/dist/starter/supabase/tests/database/chat_people.test.sql +1 -1
- package/dist/starter/supabase/tests/database/genesis_chat.test.sql +10 -2
- package/dist/starter/supabase/tests/database/genesis_chat_coaching.test.sql +8 -0
- package/dist/starter/supabase/tests/database/genesis_chat_search_threads.test.sql +8 -0
- package/dist/starter/supabase/tests/database/genesis_chat_tenants.test.sql +259 -0
- package/dist/starter/supabase/tests/database/genesis_support.test.sql +15 -3
- package/dist/starter/supabase/tests/database/genesis_support_findings.test.sql +10 -0
- package/dist/starter/supabase/tests/database/genesis_support_tickets.test.sql +327 -0
- package/dist/starter/supabase/tests/database/starter_tenancy.test.sql +19 -0
- package/dist/vite.js +270 -8
- package/dist/vite.js.map +1 -1
- package/package.json +18 -4
package/dist/eslint.cjs
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var module$1 = require('module');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var url = require('url');
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
26
|
+
|
|
27
|
+
// ../../node_modules/tsup/assets/cjs_shims.js
|
|
28
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
29
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
30
|
+
var TEST_FILES = ["**/__tests__/**/*.{js,jsx,ts,tsx}", "**/*.test.{js,jsx,ts,tsx}"];
|
|
31
|
+
var RNTL_ASYNC_CALLS = ["render", "renderHook", "renderRouter", "renderApp", "act"];
|
|
32
|
+
var TESTING_LIBRARY_PLUGIN = "eslint-plugin-testing-library";
|
|
33
|
+
var here = typeof __filename === "string" ? __filename : url.fileURLToPath(importMetaUrl);
|
|
34
|
+
function loadTestingLibrary() {
|
|
35
|
+
const from = [path__namespace.join(process.cwd(), "package.json"), here];
|
|
36
|
+
for (const base of from) {
|
|
37
|
+
try {
|
|
38
|
+
const mod = module$1.createRequire(base)(TESTING_LIBRARY_PLUGIN);
|
|
39
|
+
return mod && typeof mod === "object" && "rules" in mod ? mod : mod.default ?? mod;
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
throw new Error(
|
|
44
|
+
`@marktiderman/genesis-cli/eslint: Genesis's testing rules need ${TESTING_LIBRARY_PLUGIN}. Install it in the app's devDependencies (pnpm add -D ${TESTING_LIBRARY_PLUGIN}), or pass it as { testingLibrary: require("${TESTING_LIBRARY_PLUGIN}") }.`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
var escape = (name) => name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
48
|
+
function unawaited(message, ...callees) {
|
|
49
|
+
return callees.flatMap((callee) => [
|
|
50
|
+
{ selector: `ExpressionStatement > CallExpression${callee}`, message },
|
|
51
|
+
{ selector: `VariableDeclarator > CallExpression${callee}`, message },
|
|
52
|
+
{ selector: `AssignmentExpression > CallExpression${callee}`, message }
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
function rntlAwaitSelectors(options = {}) {
|
|
56
|
+
const calls = [.../* @__PURE__ */ new Set([...RNTL_ASYNC_CALLS, ...options.renders ?? []])].map(escape).join("|");
|
|
57
|
+
return [
|
|
58
|
+
...unawaited(
|
|
59
|
+
"React Native Testing Library 14's render calls (render, renderHook, renderRouter, renderApp) and act return promises: await them.",
|
|
60
|
+
`[callee.name=/^(${calls})$/]`
|
|
61
|
+
),
|
|
62
|
+
...unawaited(
|
|
63
|
+
"React Native Testing Library 14's rerender and unmount return promises: await them.",
|
|
64
|
+
"[callee.property.name=/^(rerender|unmount)$/]",
|
|
65
|
+
"[callee.name=/^(rerender|unmount)$/]"
|
|
66
|
+
),
|
|
67
|
+
...unawaited(
|
|
68
|
+
"userEvent's events return promises: await them.",
|
|
69
|
+
'[callee.object.type="CallExpression"][callee.object.callee.object.name="userEvent"][callee.object.callee.property.name="setup"]'
|
|
70
|
+
)
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
function testing(options = {}) {
|
|
74
|
+
return [
|
|
75
|
+
{
|
|
76
|
+
name: "genesis/testing",
|
|
77
|
+
files: options.testFiles ?? TEST_FILES,
|
|
78
|
+
plugins: { "testing-library": options.testingLibrary ?? loadTestingLibrary() },
|
|
79
|
+
rules: {
|
|
80
|
+
"testing-library/await-async-events": ["error", { eventModule: ["fireEvent", "userEvent"] }],
|
|
81
|
+
"no-restricted-syntax": ["error", ...rntlAwaitSelectors(options)]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
function genesis(platform, options = {}) {
|
|
87
|
+
if (platform === "native") return [...testing(options)];
|
|
88
|
+
if (platform === "web") return [];
|
|
89
|
+
throw new Error(`@marktiderman/genesis-cli/eslint: genesis("${String(platform)}"): the platform is "native" or "web".`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
exports.RNTL_ASYNC_CALLS = RNTL_ASYNC_CALLS;
|
|
93
|
+
exports.TESTING_LIBRARY_PLUGIN = TESTING_LIBRARY_PLUGIN;
|
|
94
|
+
exports.TEST_FILES = TEST_FILES;
|
|
95
|
+
exports.genesis = genesis;
|
|
96
|
+
exports.rntlAwaitSelectors = rntlAwaitSelectors;
|
|
97
|
+
exports.testing = testing;
|
|
98
|
+
//# sourceMappingURL=eslint.cjs.map
|
|
99
|
+
//# sourceMappingURL=eslint.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/tsup/assets/cjs_shims.js","../src/eslint.ts"],"names":["fileURLToPath","path","createRequire"],"mappings":";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A,EAAS,EAAE,aAAa,CAAC,WAAA,EAAa,WAAW,CAAA,EAAG,CAAA;AAAA,QAC3F,wBAAwB,CAAC,OAAA,EAAS,GAAG,kBAAA,CAAmB,OAAO,CAAC;AAAA;AAClE;AACF,GACF;AACF;AASO,SAAS,OAAA,CAAQ,QAAA,EAA2B,OAAA,GAA8B,EAAC,EAAwB;AACxG,EAAA,IAAI,aAAa,QAAA,EAAU,OAAO,CAAC,GAAG,OAAA,CAAQ,OAAO,CAAC,CAAA;AACtD,EAAA,IAAI,QAAA,KAAa,KAAA,EAAO,OAAO,EAAC;AAChC,EAAA,MAAM,IAAI,KAAA,CAAM,CAAA,2CAAA,EAA8C,MAAA,CAAO,QAAQ,CAAC,CAAA,sCAAA,CAAwC,CAAA;AACxH","file":"eslint.cjs","sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","/**\n * `@marktiderman/genesis-cli/eslint`: Genesis's lint rules for apps, as ESLint flat-config pieces.\n * An app spreads them into its `eslint.config.js`, and `genesis upgrade` delivers new and changed\n * rules with the CLI, so the app's config never has to change for them:\n *\n * ```js\n * const { genesis } = require(\"@marktiderman/genesis-cli/eslint\");\n * module.exports = defineConfig([expoConfig, ...genesis(\"native\")]);\n * ```\n *\n * Built for `require` and `import` alike. Plugins are loaded only when a piece that needs them is\n * built, never on import: `testing` needs `eslint-plugin-testing-library` (an optional peer\n * dependency of genesis-cli; install it in the app's devDependencies).\n */\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/** One flat-config object, as much of ESLint's `Linter.Config` as the pieces use. */\nexport interface GenesisLintConfig {\n name?: string;\n files?: string[];\n ignores?: string[];\n plugins?: Record<string, unknown>;\n rules?: Record<string, unknown>;\n}\n\n/** The platform an app is built for. */\nexport type GenesisPlatform = \"native\" | \"web\";\n\nexport interface GenesisLintOptions {\n /**\n * The test files the testing rules cover. Default: files under `__tests__/` and\n * `*.test.*` files ({@link TEST_FILES}).\n */\n testFiles?: string[];\n /**\n * The app's own helpers that wrap React Native Testing Library's `render` (and so return a\n * promise), checked like `render`. `renderApp` (the starter's helper) and expo-router's\n * `renderRouter` are always checked.\n */\n renders?: string[];\n /**\n * `eslint-plugin-testing-library`, when the app loads it itself (say, to configure more of its\n * rules). Otherwise it is resolved from the app (the working directory), then from genesis-cli.\n */\n testingLibrary?: unknown;\n}\n\n/** The test files the testing rules cover by default. */\nexport const TEST_FILES = [\"**/__tests__/**/*.{js,jsx,ts,tsx}\", \"**/*.test.{js,jsx,ts,tsx}\"];\n\n/** What React Native Testing Library 14 made async, beyond fireEvent: render calls and act. */\nexport const RNTL_ASYNC_CALLS = [\"render\", \"renderHook\", \"renderRouter\", \"renderApp\", \"act\"] as const;\n\n/** The plugin's package name, for the error when it isn't installed. */\nexport const TESTING_LIBRARY_PLUGIN = \"eslint-plugin-testing-library\";\n\nconst here = typeof __filename === \"string\" ? __filename : fileURLToPath(import.meta.url);\n\n/** `eslint-plugin-testing-library`, from the app first (the copy its own config would load), then from genesis-cli. */\nfunction loadTestingLibrary(): unknown {\n const from = [path.join(process.cwd(), \"package.json\"), here];\n for (const base of from) {\n try {\n const mod = createRequire(base)(TESTING_LIBRARY_PLUGIN) as { default?: unknown };\n return mod && typeof mod === \"object\" && \"rules\" in mod ? mod : (mod.default ?? mod);\n } catch {\n // try the next place\n }\n }\n throw new Error(\n `@marktiderman/genesis-cli/eslint: Genesis's testing rules need ${TESTING_LIBRARY_PLUGIN}. Install it in the app's devDependencies (pnpm add -D ${TESTING_LIBRARY_PLUGIN}), or pass it as { testingLibrary: require(\"${TESTING_LIBRARY_PLUGIN}\") }.`,\n );\n}\n\nconst escape = (name: string) => name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** One `no-restricted-syntax` entry per place a call's promise is dropped: a statement, a declaration, an assignment. */\nfunction unawaited(message: string, ...callees: string[]): { selector: string; message: string }[] {\n return callees.flatMap((callee) => [\n { selector: `ExpressionStatement > CallExpression${callee}`, message },\n { selector: `VariableDeclarator > CallExpression${callee}`, message },\n { selector: `AssignmentExpression > CallExpression${callee}`, message },\n ]);\n}\n\n/**\n * The `no-restricted-syntax` entries for React Native Testing Library 14's async calls: render,\n * renderHook, renderRouter, renderApp (plus `renders`) and act; rerender and unmount, as methods\n * and destructured; and a chained `userEvent.setup().press(…)`, which await-async-events doesn't\n * follow. Each flags a call whose promise is dropped (a statement, a declaration, an assignment).\n * Exported so an app with its own `no-restricted-syntax` for test files can keep both.\n */\nexport function rntlAwaitSelectors(options: Pick<GenesisLintOptions, \"renders\"> = {}): { selector: string; message: string }[] {\n const calls = [...new Set([...RNTL_ASYNC_CALLS, ...(options.renders ?? [])])].map(escape).join(\"|\");\n return [\n ...unawaited(\n \"React Native Testing Library 14's render calls (render, renderHook, renderRouter, renderApp) and act return promises: await them.\",\n `[callee.name=/^(${calls})$/]`,\n ),\n ...unawaited(\n \"React Native Testing Library 14's rerender and unmount return promises: await them.\",\n \"[callee.property.name=/^(rerender|unmount)$/]\",\n \"[callee.name=/^(rerender|unmount)$/]\",\n ),\n ...unawaited(\n \"userEvent's events return promises: await them.\",\n '[callee.object.type=\"CallExpression\"][callee.object.callee.object.name=\"userEvent\"][callee.object.callee.property.name=\"setup\"]',\n ),\n ];\n}\n\n/**\n * React Native Testing Library 14's await rules, for test files. RNTL 14 made render, renderHook,\n * fireEvent, act, rerender and unmount async; left unawaited, a test reads the screen before React\n * has updated it, and React logs \"overlapping act() calls\".\n *\n * - `testing-library/await-async-events` with `eventModule: [\"fireEvent\", \"userEvent\"]` (its\n * React preset assumes fireEvent is sync, so only this rule is turned on);\n * - `no-restricted-syntax` for what the plugin has no rule for ({@link rntlAwaitSelectors}).\n *\n * The piece sets `no-restricted-syntax` for test files, so an app's own setting of that rule for\n * the same files, later in the array, replaces it: spread `rntlAwaitSelectors()` into yours.\n */\nexport function testing(options: GenesisLintOptions = {}): GenesisLintConfig[] {\n return [\n {\n name: \"genesis/testing\",\n files: options.testFiles ?? TEST_FILES,\n plugins: { \"testing-library\": options.testingLibrary ?? loadTestingLibrary() },\n rules: {\n \"testing-library/await-async-events\": [\"error\", { eventModule: [\"fireEvent\", \"userEvent\"] }],\n \"no-restricted-syntax\": [\"error\", ...rntlAwaitSelectors(options)],\n },\n },\n ];\n}\n\n/**\n * Every Genesis lint piece for the platform, so rules a release adds arrive without an app edit:\n *\n * - `\"native\"`: {@link testing}.\n * - `\"web\"`: none yet. Testing Library for React keeps `render` and `fireEvent` synchronous, so the\n * RNTL await rules don't apply; spreading it now means web rules arrive when Genesis has some.\n */\nexport function genesis(platform: GenesisPlatform, options: GenesisLintOptions = {}): GenesisLintConfig[] {\n if (platform === \"native\") return [...testing(options)];\n if (platform === \"web\") return [];\n throw new Error(`@marktiderman/genesis-cli/eslint: genesis(\"${String(platform)}\"): the platform is \"native\" or \"web\".`);\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** One flat-config object, as much of ESLint's `Linter.Config` as the pieces use. */
|
|
2
|
+
interface GenesisLintConfig {
|
|
3
|
+
name?: string;
|
|
4
|
+
files?: string[];
|
|
5
|
+
ignores?: string[];
|
|
6
|
+
plugins?: Record<string, unknown>;
|
|
7
|
+
rules?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
/** The platform an app is built for. */
|
|
10
|
+
type GenesisPlatform = "native" | "web";
|
|
11
|
+
interface GenesisLintOptions {
|
|
12
|
+
/**
|
|
13
|
+
* The test files the testing rules cover. Default: files under `__tests__/` and
|
|
14
|
+
* `*.test.*` files ({@link TEST_FILES}).
|
|
15
|
+
*/
|
|
16
|
+
testFiles?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* The app's own helpers that wrap React Native Testing Library's `render` (and so return a
|
|
19
|
+
* promise), checked like `render`. `renderApp` (the starter's helper) and expo-router's
|
|
20
|
+
* `renderRouter` are always checked.
|
|
21
|
+
*/
|
|
22
|
+
renders?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* `eslint-plugin-testing-library`, when the app loads it itself (say, to configure more of its
|
|
25
|
+
* rules). Otherwise it is resolved from the app (the working directory), then from genesis-cli.
|
|
26
|
+
*/
|
|
27
|
+
testingLibrary?: unknown;
|
|
28
|
+
}
|
|
29
|
+
/** The test files the testing rules cover by default. */
|
|
30
|
+
declare const TEST_FILES: string[];
|
|
31
|
+
/** What React Native Testing Library 14 made async, beyond fireEvent: render calls and act. */
|
|
32
|
+
declare const RNTL_ASYNC_CALLS: readonly ["render", "renderHook", "renderRouter", "renderApp", "act"];
|
|
33
|
+
/** The plugin's package name, for the error when it isn't installed. */
|
|
34
|
+
declare const TESTING_LIBRARY_PLUGIN = "eslint-plugin-testing-library";
|
|
35
|
+
/**
|
|
36
|
+
* The `no-restricted-syntax` entries for React Native Testing Library 14's async calls: render,
|
|
37
|
+
* renderHook, renderRouter, renderApp (plus `renders`) and act; rerender and unmount, as methods
|
|
38
|
+
* and destructured; and a chained `userEvent.setup().press(…)`, which await-async-events doesn't
|
|
39
|
+
* follow. Each flags a call whose promise is dropped (a statement, a declaration, an assignment).
|
|
40
|
+
* Exported so an app with its own `no-restricted-syntax` for test files can keep both.
|
|
41
|
+
*/
|
|
42
|
+
declare function rntlAwaitSelectors(options?: Pick<GenesisLintOptions, "renders">): {
|
|
43
|
+
selector: string;
|
|
44
|
+
message: string;
|
|
45
|
+
}[];
|
|
46
|
+
/**
|
|
47
|
+
* React Native Testing Library 14's await rules, for test files. RNTL 14 made render, renderHook,
|
|
48
|
+
* fireEvent, act, rerender and unmount async; left unawaited, a test reads the screen before React
|
|
49
|
+
* has updated it, and React logs "overlapping act() calls".
|
|
50
|
+
*
|
|
51
|
+
* - `testing-library/await-async-events` with `eventModule: ["fireEvent", "userEvent"]` (its
|
|
52
|
+
* React preset assumes fireEvent is sync, so only this rule is turned on);
|
|
53
|
+
* - `no-restricted-syntax` for what the plugin has no rule for ({@link rntlAwaitSelectors}).
|
|
54
|
+
*
|
|
55
|
+
* The piece sets `no-restricted-syntax` for test files, so an app's own setting of that rule for
|
|
56
|
+
* the same files, later in the array, replaces it: spread `rntlAwaitSelectors()` into yours.
|
|
57
|
+
*/
|
|
58
|
+
declare function testing(options?: GenesisLintOptions): GenesisLintConfig[];
|
|
59
|
+
/**
|
|
60
|
+
* Every Genesis lint piece for the platform, so rules a release adds arrive without an app edit:
|
|
61
|
+
*
|
|
62
|
+
* - `"native"`: {@link testing}.
|
|
63
|
+
* - `"web"`: none yet. Testing Library for React keeps `render` and `fireEvent` synchronous, so the
|
|
64
|
+
* RNTL await rules don't apply; spreading it now means web rules arrive when Genesis has some.
|
|
65
|
+
*/
|
|
66
|
+
declare function genesis(platform: GenesisPlatform, options?: GenesisLintOptions): GenesisLintConfig[];
|
|
67
|
+
|
|
68
|
+
export { type GenesisLintConfig, type GenesisLintOptions, type GenesisPlatform, RNTL_ASYNC_CALLS, TESTING_LIBRARY_PLUGIN, TEST_FILES, genesis, rntlAwaitSelectors, testing };
|
package/dist/eslint.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** One flat-config object, as much of ESLint's `Linter.Config` as the pieces use. */
|
|
2
|
+
interface GenesisLintConfig {
|
|
3
|
+
name?: string;
|
|
4
|
+
files?: string[];
|
|
5
|
+
ignores?: string[];
|
|
6
|
+
plugins?: Record<string, unknown>;
|
|
7
|
+
rules?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
/** The platform an app is built for. */
|
|
10
|
+
type GenesisPlatform = "native" | "web";
|
|
11
|
+
interface GenesisLintOptions {
|
|
12
|
+
/**
|
|
13
|
+
* The test files the testing rules cover. Default: files under `__tests__/` and
|
|
14
|
+
* `*.test.*` files ({@link TEST_FILES}).
|
|
15
|
+
*/
|
|
16
|
+
testFiles?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* The app's own helpers that wrap React Native Testing Library's `render` (and so return a
|
|
19
|
+
* promise), checked like `render`. `renderApp` (the starter's helper) and expo-router's
|
|
20
|
+
* `renderRouter` are always checked.
|
|
21
|
+
*/
|
|
22
|
+
renders?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* `eslint-plugin-testing-library`, when the app loads it itself (say, to configure more of its
|
|
25
|
+
* rules). Otherwise it is resolved from the app (the working directory), then from genesis-cli.
|
|
26
|
+
*/
|
|
27
|
+
testingLibrary?: unknown;
|
|
28
|
+
}
|
|
29
|
+
/** The test files the testing rules cover by default. */
|
|
30
|
+
declare const TEST_FILES: string[];
|
|
31
|
+
/** What React Native Testing Library 14 made async, beyond fireEvent: render calls and act. */
|
|
32
|
+
declare const RNTL_ASYNC_CALLS: readonly ["render", "renderHook", "renderRouter", "renderApp", "act"];
|
|
33
|
+
/** The plugin's package name, for the error when it isn't installed. */
|
|
34
|
+
declare const TESTING_LIBRARY_PLUGIN = "eslint-plugin-testing-library";
|
|
35
|
+
/**
|
|
36
|
+
* The `no-restricted-syntax` entries for React Native Testing Library 14's async calls: render,
|
|
37
|
+
* renderHook, renderRouter, renderApp (plus `renders`) and act; rerender and unmount, as methods
|
|
38
|
+
* and destructured; and a chained `userEvent.setup().press(…)`, which await-async-events doesn't
|
|
39
|
+
* follow. Each flags a call whose promise is dropped (a statement, a declaration, an assignment).
|
|
40
|
+
* Exported so an app with its own `no-restricted-syntax` for test files can keep both.
|
|
41
|
+
*/
|
|
42
|
+
declare function rntlAwaitSelectors(options?: Pick<GenesisLintOptions, "renders">): {
|
|
43
|
+
selector: string;
|
|
44
|
+
message: string;
|
|
45
|
+
}[];
|
|
46
|
+
/**
|
|
47
|
+
* React Native Testing Library 14's await rules, for test files. RNTL 14 made render, renderHook,
|
|
48
|
+
* fireEvent, act, rerender and unmount async; left unawaited, a test reads the screen before React
|
|
49
|
+
* has updated it, and React logs "overlapping act() calls".
|
|
50
|
+
*
|
|
51
|
+
* - `testing-library/await-async-events` with `eventModule: ["fireEvent", "userEvent"]` (its
|
|
52
|
+
* React preset assumes fireEvent is sync, so only this rule is turned on);
|
|
53
|
+
* - `no-restricted-syntax` for what the plugin has no rule for ({@link rntlAwaitSelectors}).
|
|
54
|
+
*
|
|
55
|
+
* The piece sets `no-restricted-syntax` for test files, so an app's own setting of that rule for
|
|
56
|
+
* the same files, later in the array, replaces it: spread `rntlAwaitSelectors()` into yours.
|
|
57
|
+
*/
|
|
58
|
+
declare function testing(options?: GenesisLintOptions): GenesisLintConfig[];
|
|
59
|
+
/**
|
|
60
|
+
* Every Genesis lint piece for the platform, so rules a release adds arrive without an app edit:
|
|
61
|
+
*
|
|
62
|
+
* - `"native"`: {@link testing}.
|
|
63
|
+
* - `"web"`: none yet. Testing Library for React keeps `render` and `fireEvent` synchronous, so the
|
|
64
|
+
* RNTL await rules don't apply; spreading it now means web rules arrive when Genesis has some.
|
|
65
|
+
*/
|
|
66
|
+
declare function genesis(platform: GenesisPlatform, options?: GenesisLintOptions): GenesisLintConfig[];
|
|
67
|
+
|
|
68
|
+
export { type GenesisLintConfig, type GenesisLintOptions, type GenesisPlatform, RNTL_ASYNC_CALLS, TESTING_LIBRARY_PLUGIN, TEST_FILES, genesis, rntlAwaitSelectors, testing };
|
package/dist/eslint.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as path2 from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
|
+
|
|
5
|
+
// ../../node_modules/tsup/assets/esm_shims.js
|
|
6
|
+
var getFilename = () => fileURLToPath(import.meta.url);
|
|
7
|
+
var __filename$1 = /* @__PURE__ */ getFilename();
|
|
8
|
+
var TEST_FILES = ["**/__tests__/**/*.{js,jsx,ts,tsx}", "**/*.test.{js,jsx,ts,tsx}"];
|
|
9
|
+
var RNTL_ASYNC_CALLS = ["render", "renderHook", "renderRouter", "renderApp", "act"];
|
|
10
|
+
var TESTING_LIBRARY_PLUGIN = "eslint-plugin-testing-library";
|
|
11
|
+
var here = typeof __filename$1 === "string" ? __filename$1 : fileURLToPath(import.meta.url);
|
|
12
|
+
function loadTestingLibrary() {
|
|
13
|
+
const from = [path2.join(process.cwd(), "package.json"), here];
|
|
14
|
+
for (const base of from) {
|
|
15
|
+
try {
|
|
16
|
+
const mod = createRequire(base)(TESTING_LIBRARY_PLUGIN);
|
|
17
|
+
return mod && typeof mod === "object" && "rules" in mod ? mod : mod.default ?? mod;
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
throw new Error(
|
|
22
|
+
`@marktiderman/genesis-cli/eslint: Genesis's testing rules need ${TESTING_LIBRARY_PLUGIN}. Install it in the app's devDependencies (pnpm add -D ${TESTING_LIBRARY_PLUGIN}), or pass it as { testingLibrary: require("${TESTING_LIBRARY_PLUGIN}") }.`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
var escape = (name) => name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
26
|
+
function unawaited(message, ...callees) {
|
|
27
|
+
return callees.flatMap((callee) => [
|
|
28
|
+
{ selector: `ExpressionStatement > CallExpression${callee}`, message },
|
|
29
|
+
{ selector: `VariableDeclarator > CallExpression${callee}`, message },
|
|
30
|
+
{ selector: `AssignmentExpression > CallExpression${callee}`, message }
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
function rntlAwaitSelectors(options = {}) {
|
|
34
|
+
const calls = [.../* @__PURE__ */ new Set([...RNTL_ASYNC_CALLS, ...options.renders ?? []])].map(escape).join("|");
|
|
35
|
+
return [
|
|
36
|
+
...unawaited(
|
|
37
|
+
"React Native Testing Library 14's render calls (render, renderHook, renderRouter, renderApp) and act return promises: await them.",
|
|
38
|
+
`[callee.name=/^(${calls})$/]`
|
|
39
|
+
),
|
|
40
|
+
...unawaited(
|
|
41
|
+
"React Native Testing Library 14's rerender and unmount return promises: await them.",
|
|
42
|
+
"[callee.property.name=/^(rerender|unmount)$/]",
|
|
43
|
+
"[callee.name=/^(rerender|unmount)$/]"
|
|
44
|
+
),
|
|
45
|
+
...unawaited(
|
|
46
|
+
"userEvent's events return promises: await them.",
|
|
47
|
+
'[callee.object.type="CallExpression"][callee.object.callee.object.name="userEvent"][callee.object.callee.property.name="setup"]'
|
|
48
|
+
)
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
function testing(options = {}) {
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
name: "genesis/testing",
|
|
55
|
+
files: options.testFiles ?? TEST_FILES,
|
|
56
|
+
plugins: { "testing-library": options.testingLibrary ?? loadTestingLibrary() },
|
|
57
|
+
rules: {
|
|
58
|
+
"testing-library/await-async-events": ["error", { eventModule: ["fireEvent", "userEvent"] }],
|
|
59
|
+
"no-restricted-syntax": ["error", ...rntlAwaitSelectors(options)]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
function genesis(platform, options = {}) {
|
|
65
|
+
if (platform === "native") return [...testing(options)];
|
|
66
|
+
if (platform === "web") return [];
|
|
67
|
+
throw new Error(`@marktiderman/genesis-cli/eslint: genesis("${String(platform)}"): the platform is "native" or "web".`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { RNTL_ASYNC_CALLS, TESTING_LIBRARY_PLUGIN, TEST_FILES, genesis, rntlAwaitSelectors, testing };
|
|
71
|
+
//# sourceMappingURL=eslint.js.map
|
|
72
|
+
//# sourceMappingURL=eslint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/tsup/assets/esm_shims.js","../src/eslint.ts"],"names":["__filename","fileURLToPath"],"mappings":";;;;;AAIA,IAAM,WAAA,GAAc,MAAM,aAAA,CAA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QAAA,KAAa,KAAA,EAAO,OAAO,EAAC;AAChC,EAAA,MAAM,IAAI,KAAA,CAAM,CAAA,2CAAA,EAA8C,MAAA,CAAO,QAAQ,CAAC,CAAA,sCAAA,CAAwC,CAAA;AACxH","file":"eslint.js","sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","/**\n * `@marktiderman/genesis-cli/eslint`: Genesis's lint rules for apps, as ESLint flat-config pieces.\n * An app spreads them into its `eslint.config.js`, and `genesis upgrade` delivers new and changed\n * rules with the CLI, so the app's config never has to change for them:\n *\n * ```js\n * const { genesis } = require(\"@marktiderman/genesis-cli/eslint\");\n * module.exports = defineConfig([expoConfig, ...genesis(\"native\")]);\n * ```\n *\n * Built for `require` and `import` alike. Plugins are loaded only when a piece that needs them is\n * built, never on import: `testing` needs `eslint-plugin-testing-library` (an optional peer\n * dependency of genesis-cli; install it in the app's devDependencies).\n */\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/** One flat-config object, as much of ESLint's `Linter.Config` as the pieces use. */\nexport interface GenesisLintConfig {\n name?: string;\n files?: string[];\n ignores?: string[];\n plugins?: Record<string, unknown>;\n rules?: Record<string, unknown>;\n}\n\n/** The platform an app is built for. */\nexport type GenesisPlatform = \"native\" | \"web\";\n\nexport interface GenesisLintOptions {\n /**\n * The test files the testing rules cover. Default: files under `__tests__/` and\n * `*.test.*` files ({@link TEST_FILES}).\n */\n testFiles?: string[];\n /**\n * The app's own helpers that wrap React Native Testing Library's `render` (and so return a\n * promise), checked like `render`. `renderApp` (the starter's helper) and expo-router's\n * `renderRouter` are always checked.\n */\n renders?: string[];\n /**\n * `eslint-plugin-testing-library`, when the app loads it itself (say, to configure more of its\n * rules). Otherwise it is resolved from the app (the working directory), then from genesis-cli.\n */\n testingLibrary?: unknown;\n}\n\n/** The test files the testing rules cover by default. */\nexport const TEST_FILES = [\"**/__tests__/**/*.{js,jsx,ts,tsx}\", \"**/*.test.{js,jsx,ts,tsx}\"];\n\n/** What React Native Testing Library 14 made async, beyond fireEvent: render calls and act. */\nexport const RNTL_ASYNC_CALLS = [\"render\", \"renderHook\", \"renderRouter\", \"renderApp\", \"act\"] as const;\n\n/** The plugin's package name, for the error when it isn't installed. */\nexport const TESTING_LIBRARY_PLUGIN = \"eslint-plugin-testing-library\";\n\nconst here = typeof __filename === \"string\" ? __filename : fileURLToPath(import.meta.url);\n\n/** `eslint-plugin-testing-library`, from the app first (the copy its own config would load), then from genesis-cli. */\nfunction loadTestingLibrary(): unknown {\n const from = [path.join(process.cwd(), \"package.json\"), here];\n for (const base of from) {\n try {\n const mod = createRequire(base)(TESTING_LIBRARY_PLUGIN) as { default?: unknown };\n return mod && typeof mod === \"object\" && \"rules\" in mod ? mod : (mod.default ?? mod);\n } catch {\n // try the next place\n }\n }\n throw new Error(\n `@marktiderman/genesis-cli/eslint: Genesis's testing rules need ${TESTING_LIBRARY_PLUGIN}. Install it in the app's devDependencies (pnpm add -D ${TESTING_LIBRARY_PLUGIN}), or pass it as { testingLibrary: require(\"${TESTING_LIBRARY_PLUGIN}\") }.`,\n );\n}\n\nconst escape = (name: string) => name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** One `no-restricted-syntax` entry per place a call's promise is dropped: a statement, a declaration, an assignment. */\nfunction unawaited(message: string, ...callees: string[]): { selector: string; message: string }[] {\n return callees.flatMap((callee) => [\n { selector: `ExpressionStatement > CallExpression${callee}`, message },\n { selector: `VariableDeclarator > CallExpression${callee}`, message },\n { selector: `AssignmentExpression > CallExpression${callee}`, message },\n ]);\n}\n\n/**\n * The `no-restricted-syntax` entries for React Native Testing Library 14's async calls: render,\n * renderHook, renderRouter, renderApp (plus `renders`) and act; rerender and unmount, as methods\n * and destructured; and a chained `userEvent.setup().press(…)`, which await-async-events doesn't\n * follow. Each flags a call whose promise is dropped (a statement, a declaration, an assignment).\n * Exported so an app with its own `no-restricted-syntax` for test files can keep both.\n */\nexport function rntlAwaitSelectors(options: Pick<GenesisLintOptions, \"renders\"> = {}): { selector: string; message: string }[] {\n const calls = [...new Set([...RNTL_ASYNC_CALLS, ...(options.renders ?? [])])].map(escape).join(\"|\");\n return [\n ...unawaited(\n \"React Native Testing Library 14's render calls (render, renderHook, renderRouter, renderApp) and act return promises: await them.\",\n `[callee.name=/^(${calls})$/]`,\n ),\n ...unawaited(\n \"React Native Testing Library 14's rerender and unmount return promises: await them.\",\n \"[callee.property.name=/^(rerender|unmount)$/]\",\n \"[callee.name=/^(rerender|unmount)$/]\",\n ),\n ...unawaited(\n \"userEvent's events return promises: await them.\",\n '[callee.object.type=\"CallExpression\"][callee.object.callee.object.name=\"userEvent\"][callee.object.callee.property.name=\"setup\"]',\n ),\n ];\n}\n\n/**\n * React Native Testing Library 14's await rules, for test files. RNTL 14 made render, renderHook,\n * fireEvent, act, rerender and unmount async; left unawaited, a test reads the screen before React\n * has updated it, and React logs \"overlapping act() calls\".\n *\n * - `testing-library/await-async-events` with `eventModule: [\"fireEvent\", \"userEvent\"]` (its\n * React preset assumes fireEvent is sync, so only this rule is turned on);\n * - `no-restricted-syntax` for what the plugin has no rule for ({@link rntlAwaitSelectors}).\n *\n * The piece sets `no-restricted-syntax` for test files, so an app's own setting of that rule for\n * the same files, later in the array, replaces it: spread `rntlAwaitSelectors()` into yours.\n */\nexport function testing(options: GenesisLintOptions = {}): GenesisLintConfig[] {\n return [\n {\n name: \"genesis/testing\",\n files: options.testFiles ?? TEST_FILES,\n plugins: { \"testing-library\": options.testingLibrary ?? loadTestingLibrary() },\n rules: {\n \"testing-library/await-async-events\": [\"error\", { eventModule: [\"fireEvent\", \"userEvent\"] }],\n \"no-restricted-syntax\": [\"error\", ...rntlAwaitSelectors(options)],\n },\n },\n ];\n}\n\n/**\n * Every Genesis lint piece for the platform, so rules a release adds arrive without an app edit:\n *\n * - `\"native\"`: {@link testing}.\n * - `\"web\"`: none yet. Testing Library for React keeps `render` and `fireEvent` synchronous, so the\n * RNTL await rules don't apply; spreading it now means web rules arrive when Genesis has some.\n */\nexport function genesis(platform: GenesisPlatform, options: GenesisLintOptions = {}): GenesisLintConfig[] {\n if (platform === \"native\") return [...testing(options)];\n if (platform === \"web\") return [];\n throw new Error(`@marktiderman/genesis-cli/eslint: genesis(\"${String(platform)}\"): the platform is \"native\" or \"web\".`);\n}\n"]}
|
|
@@ -31,8 +31,11 @@
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
+
"@marktiderman/genesis-calendar": {
|
|
35
|
+
"version": "0.1.2"
|
|
36
|
+
},
|
|
34
37
|
"@marktiderman/genesis-chat": {
|
|
35
|
-
"version": "0.
|
|
38
|
+
"version": "0.8.0",
|
|
36
39
|
"blocks": {
|
|
37
40
|
"chat": {
|
|
38
41
|
"feature": {
|
|
@@ -70,12 +73,23 @@
|
|
|
70
73
|
{
|
|
71
74
|
"file": "migrations/0003_genesis_chat_search_threads.sql",
|
|
72
75
|
"test": "migrations/tests/0003_genesis_chat_search_threads.test.sql"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"file": "migrations/0004_genesis_chat_tenants.sql",
|
|
79
|
+
"test": "migrations/tests/0004_genesis_chat_tenants.test.sql",
|
|
80
|
+
"needs": [
|
|
81
|
+
{
|
|
82
|
+
"function": "private.genesis_viewer_people",
|
|
83
|
+
"how": "every conversation is in a tenant from chat 0004. Add a migration before it that defines private.genesis_viewer_people(viewer uuid) returns table (tenant_id uuid, person_id uuid): one row per tenant the login is in (a single-tenant app returns its one tenant id; a personal record's tenant can be its own id). See genesis-supabase 0016's header."
|
|
84
|
+
}
|
|
85
|
+
]
|
|
73
86
|
}
|
|
74
87
|
],
|
|
75
88
|
"install": [
|
|
76
89
|
"@supabase/supabase-js@^2.118.0"
|
|
77
90
|
],
|
|
78
91
|
"steps": [
|
|
92
|
+
"Say who belongs to which tenant: private.genesis_viewer_people(viewer uuid) returns table (tenant_id uuid, person_id uuid), the hook genesis-supabase's 0016 documents (a single-tenant app returns its one tenant). Every conversation belongs to a tenant from migration 0004.",
|
|
79
93
|
"Expose the genesis_chat schema to the API: add it to `schemas` under [api] in supabase/config.toml, and to Exposed schemas in the dashboard.",
|
|
80
94
|
"Register your kinds' rules in a migration of your own, after this one: a start check for direct (who may message whom) and any kinds of your own, with an observer check where staff read without being members (genesis-chat README, Kinds and rules).",
|
|
81
95
|
"Run the outbox: call createChatRunner from @marktiderman/genesis-chat/server on a schedule (every minute) or from a database webhook on genesis_chat.effects, with your push sender."
|
|
@@ -90,10 +104,10 @@
|
|
|
90
104
|
"version": "0.3.0"
|
|
91
105
|
},
|
|
92
106
|
"@marktiderman/genesis-core": {
|
|
93
|
-
"version": "2.
|
|
107
|
+
"version": "2.11.0"
|
|
94
108
|
},
|
|
95
109
|
"@marktiderman/genesis-design-system": {
|
|
96
|
-
"version": "1.
|
|
110
|
+
"version": "1.8.0"
|
|
97
111
|
},
|
|
98
112
|
"@marktiderman/genesis-extension": {
|
|
99
113
|
"version": "0.2.2"
|
|
@@ -123,16 +137,16 @@
|
|
|
123
137
|
"version": "0.7.0"
|
|
124
138
|
},
|
|
125
139
|
"@marktiderman/genesis": {
|
|
126
|
-
"version": "0.10.
|
|
140
|
+
"version": "0.10.15"
|
|
127
141
|
},
|
|
128
142
|
"@marktiderman/genesis-cli": {
|
|
129
|
-
"version": "1.
|
|
143
|
+
"version": "1.21.0"
|
|
130
144
|
},
|
|
131
145
|
"@marktiderman/genesis-media": {
|
|
132
146
|
"version": "0.2.0"
|
|
133
147
|
},
|
|
134
148
|
"@marktiderman/genesis-native": {
|
|
135
|
-
"version": "0.
|
|
149
|
+
"version": "0.9.0",
|
|
136
150
|
"blocks": {
|
|
137
151
|
"push": {
|
|
138
152
|
"feature": {
|
|
@@ -405,7 +419,7 @@
|
|
|
405
419
|
}
|
|
406
420
|
},
|
|
407
421
|
"@marktiderman/genesis-sites": {
|
|
408
|
-
"version": "0.5.
|
|
422
|
+
"version": "0.5.3",
|
|
409
423
|
"blocks": {
|
|
410
424
|
"sites": {
|
|
411
425
|
"feature": {
|
|
@@ -449,13 +463,13 @@
|
|
|
449
463
|
}
|
|
450
464
|
},
|
|
451
465
|
"@marktiderman/genesis-studio": {
|
|
452
|
-
"version": "0.
|
|
466
|
+
"version": "0.3.0"
|
|
453
467
|
},
|
|
454
468
|
"@marktiderman/genesis-studio-server": {
|
|
455
469
|
"version": "0.5.3"
|
|
456
470
|
},
|
|
457
471
|
"@marktiderman/genesis-supabase": {
|
|
458
|
-
"version": "0.
|
|
472
|
+
"version": "0.14.0",
|
|
459
473
|
"blocks": {
|
|
460
474
|
"account": {
|
|
461
475
|
"feature": {
|
|
@@ -660,11 +674,41 @@
|
|
|
660
674
|
"web",
|
|
661
675
|
"native"
|
|
662
676
|
]
|
|
677
|
+
},
|
|
678
|
+
"versioned-writes": {
|
|
679
|
+
"feature": {
|
|
680
|
+
"name": "Versioned writes",
|
|
681
|
+
"summary": "A trigger that advances a row's version on every update, so the Supabase data provider refuses an edit made on a stale copy as a conflict instead of overwriting someone else's.",
|
|
682
|
+
"keywords": [
|
|
683
|
+
"optimistic concurrency",
|
|
684
|
+
"version",
|
|
685
|
+
"conflict",
|
|
686
|
+
"lost update",
|
|
687
|
+
"offline"
|
|
688
|
+
],
|
|
689
|
+
"audience": [
|
|
690
|
+
"developer"
|
|
691
|
+
]
|
|
692
|
+
},
|
|
693
|
+
"platforms": [
|
|
694
|
+
"web",
|
|
695
|
+
"native"
|
|
696
|
+
],
|
|
697
|
+
"migrations": [
|
|
698
|
+
{
|
|
699
|
+
"file": "migrations/0019_genesis_version_bump.sql",
|
|
700
|
+
"test": "migrations/tests/0019_genesis_version_bump.test.sql"
|
|
701
|
+
}
|
|
702
|
+
],
|
|
703
|
+
"steps": [
|
|
704
|
+
"For each table to check: add `version bigint not null default 1` and `create trigger <table>_version_bump before update on <table> for each row execute function public.genesis_version_bump('version')`.",
|
|
705
|
+
"Give the resource a version rule in createSupabaseProvider: `resources: { tasks: { version: { field: \"version\", kind: \"integer\" } } }`. The Genesis write hooks then send the version they read, and a stale edit comes back as a conflict."
|
|
706
|
+
]
|
|
663
707
|
}
|
|
664
708
|
}
|
|
665
709
|
},
|
|
666
710
|
"@marktiderman/genesis-support": {
|
|
667
|
-
"version": "0.
|
|
711
|
+
"version": "0.5.0",
|
|
668
712
|
"blocks": {
|
|
669
713
|
"support-feedback": {
|
|
670
714
|
"feature": {
|
|
@@ -706,6 +750,20 @@
|
|
|
706
750
|
{
|
|
707
751
|
"file": "migrations/0003_genesis_support_findings.sql",
|
|
708
752
|
"test": "migrations/tests/0003_genesis_support_findings.test.sql"
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
"file": "migrations/0004_genesis_support_tickets.sql",
|
|
756
|
+
"test": "migrations/tests/0004_genesis_support_tickets.test.sql",
|
|
757
|
+
"needs": [
|
|
758
|
+
{
|
|
759
|
+
"function": "private.genesis_support_default_tenant",
|
|
760
|
+
"how": "tickets have a tenant from support 0004. Add a migration before it that defines private.genesis_support_default_tenant() returns uuid: your own tenant, where your own support lives (a single-tenant app returns its one tenant id). See 0004's header."
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
"function": "private.genesis_viewer_people",
|
|
764
|
+
"how": "a ticket's agents and the tenants a sender may write to come from it. Add a migration before support 0004 that defines private.genesis_viewer_people(viewer uuid) returns table (tenant_id uuid, person_id uuid). See genesis-supabase 0016's header."
|
|
765
|
+
}
|
|
766
|
+
]
|
|
709
767
|
}
|
|
710
768
|
],
|
|
711
769
|
"functions": [
|
|
@@ -844,8 +902,18 @@
|
|
|
844
902
|
],
|
|
845
903
|
"migrations": [
|
|
846
904
|
{
|
|
847
|
-
"file": "migrations/
|
|
905
|
+
"file": "migrations/0005_genesis_support_chat_on_tickets.sql",
|
|
848
906
|
"test": "migrations/tests/0001_genesis_support_chat.test.sql"
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
"file": "migrations/0006_genesis_support_chat_tenants.sql",
|
|
910
|
+
"test": "migrations/tests/0006_genesis_support_chat_tenants.test.sql",
|
|
911
|
+
"runsBefore": [
|
|
912
|
+
{
|
|
913
|
+
"package": "@marktiderman/genesis-chat",
|
|
914
|
+
"file": "migrations/0004_genesis_chat_tenants.sql"
|
|
915
|
+
}
|
|
916
|
+
]
|
|
849
917
|
}
|
|
850
918
|
],
|
|
851
919
|
"steps": [
|
|
@@ -884,8 +952,12 @@
|
|
|
884
952
|
],
|
|
885
953
|
"migrations": [
|
|
886
954
|
{
|
|
887
|
-
"file": "migrations/
|
|
955
|
+
"file": "migrations/0007_genesis_support_email_on_tickets.sql",
|
|
888
956
|
"test": "migrations/tests/0002_genesis_support_email.test.sql"
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
"file": "migrations/0008_genesis_support_email_tenants.sql",
|
|
960
|
+
"test": "migrations/tests/0008_genesis_support_email_tenants.test.sql"
|
|
889
961
|
}
|
|
890
962
|
],
|
|
891
963
|
"steps": [
|
|
@@ -900,10 +972,10 @@
|
|
|
900
972
|
"version": "2.1.3"
|
|
901
973
|
},
|
|
902
974
|
"@marktiderman/genesis-ui": {
|
|
903
|
-
"version": "2.
|
|
975
|
+
"version": "2.31.0"
|
|
904
976
|
},
|
|
905
977
|
"@marktiderman/genesis-ui-native": {
|
|
906
|
-
"version": "3.
|
|
978
|
+
"version": "3.6.0"
|
|
907
979
|
}
|
|
908
980
|
}
|
|
909
981
|
}
|