@tailor-platform/sdk 2.3.0 → 2.5.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/CHANGELOG.md +171 -0
- package/README.md +1 -1
- package/dist/aigateway-DsWDjzk4.mjs +2 -0
- package/dist/{aigateway-DR4Kwuik.mjs.map → aigateway-DsWDjzk4.mjs.map} +1 -1
- package/dist/application-DFOUovmN.mjs +1 -0
- package/dist/application-D_4vg1KR.mjs +192 -0
- package/dist/application-D_4vg1KR.mjs.map +1 -0
- package/dist/assert-WeXvmG4j.mjs +2 -0
- package/dist/{assert-DBxo8jPo.mjs.map → assert-WeXvmG4j.mjs.map} +1 -1
- package/dist/authconnection-CynFBIv8.mjs +2 -0
- package/dist/{authconnection-CZvi9ANm.mjs.map → authconnection-CynFBIv8.mjs.map} +1 -1
- package/dist/brand-C8nMKhJC.mjs +2 -0
- package/dist/{brand-Eo4pLXPJ.mjs.map → brand-C8nMKhJC.mjs.map} +1 -1
- package/dist/cli/commands/deploy/deploy.d.mts +2 -2
- package/dist/cli/commands/deploy/deployment-target.d.mts +2 -0
- package/dist/cli/commands/deploy/event-subscriptions.d.mts +3 -0
- package/dist/cli/commands/deploy/tailordb/apply.d.mts +3 -0
- package/dist/cli/commands/deploy/tailordb/index.d.mts +3 -10
- package/dist/cli/commands/deploy/tailordb/migration-validation.d.mts +5 -0
- package/dist/cli/commands/deploy/tailordb/plan.d.mts +8 -0
- package/dist/cli/commands/executor/jobs.d.mts +1 -1
- package/dist/cli/commands/generate/seed/bundler.d.mts +2 -2
- package/dist/cli/commands/show.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +15 -15
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +7 -3
- package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/snapshot-comparison.d.mts +43 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-files.d.mts +62 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-local.d.mts +12 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-migrations.d.mts +12 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-remote.d.mts +1 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +3 -1
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +5 -117
- package/dist/cli/commands/tailordb/truncate.d.mts +2 -2
- package/dist/cli/lib.d.mts +8 -4
- package/dist/cli/lib.mjs +1 -9
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/main.mjs +1170 -7686
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/shared/seed-chunker.d.mts +5 -5
- package/dist/cli/ts-hook.mjs +3 -1
- package/dist/completion/zsh-worker.zsh +99 -18
- package/dist/configure/config/index.d.mts +2 -2
- package/dist/configure/config/types.d.mts +2 -2
- package/dist/configure/index.d.mts +49 -12
- package/dist/configure/index.mjs +1 -1267
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/aigateway/index.d.mts +5 -4
- package/dist/configure/services/aigateway/types.d.mts +6 -1
- package/dist/configure/services/auth/types.d.mts +3 -3
- package/dist/configure/services/idp/types.d.mts +1 -1
- package/dist/configure/services/tailordb/permission.d.mts +1 -1
- package/dist/configure/services/tailordb/schema.d.mts +5 -9
- package/dist/configure/services/tailordb/types.d.mts +8 -5
- package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
- package/dist/configure/services/workflow/job.d.mts +12 -2
- package/dist/configure/types/auth-namespace-name.d.mts +18 -0
- package/dist/configure/types/field.types.d.mts +1 -1
- package/dist/configure/types/permission-operand.types.d.mts +1 -1
- package/dist/context-D0QjfxzD.mjs +2 -0
- package/dist/{context-DYQVYWqZ.mjs.map → context-D0QjfxzD.mjs.map} +1 -1
- package/dist/crashreport-B-_HTKLr.mjs +42 -0
- package/dist/{crashreport-CIIfLnoO.mjs.map → crashreport-B-_HTKLr.mjs.map} +1 -1
- package/dist/crashreport-BmsRIdpy.mjs +1 -0
- package/dist/errors-DSEXKRVD.mjs +2 -0
- package/dist/errors-DSEXKRVD.mjs.map +1 -0
- package/dist/file-COPYfju_.mjs +2 -0
- package/dist/file-COPYfju_.mjs.map +1 -0
- package/dist/globals-CMHSnj4w.mjs +2 -0
- package/dist/{globals-B2nlxBrz.mjs.map → globals-CMHSnj4w.mjs.map} +1 -1
- package/dist/iconv-DlFMt2gW.mjs +2 -0
- package/dist/{iconv-QWaZh0TT.mjs.map → iconv-DlFMt2gW.mjs.map} +1 -1
- package/dist/idp-G_ojPBB5.mjs +2 -0
- package/dist/{idp-RA_swu-h.mjs.map → idp-G_ojPBB5.mjs.map} +1 -1
- package/dist/interceptor-DQg3cR_9.mjs +2 -0
- package/dist/{interceptor-e33JtsC-.mjs.map → interceptor-DQg3cR_9.mjs.map} +1 -1
- package/dist/kysely/index.mjs +1 -31
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/kysely-type-BTi3BMtL.mjs +43 -0
- package/dist/kysely-type-BTi3BMtL.mjs.map +1 -0
- package/dist/logger-BcGy-u7G.mjs +9 -0
- package/dist/{logger-DSdExfor.mjs.map → logger-BcGy-u7G.mjs.map} +1 -1
- package/dist/logger-DP2BjQ93.mjs +2 -0
- package/dist/{logger-BtX0suGY.mjs.map → logger-DP2BjQ93.mjs.map} +1 -1
- package/dist/multiline-EyzjEwn9.mjs +3 -0
- package/dist/{multiline-sfHpTZZK.mjs.map → multiline-EyzjEwn9.mjs.map} +1 -1
- package/dist/node-builtins-oBl7EbyV.mjs +2 -0
- package/dist/{node-builtins-CmaL2Cbq.mjs.map → node-builtins-oBl7EbyV.mjs.map} +1 -1
- package/dist/package-json-C690ceex.mjs +2 -0
- package/dist/{package-json-8b0O9TlX.mjs.map → package-json-C690ceex.mjs.map} +1 -1
- package/dist/package-json-CmqhDJ__.mjs +1 -0
- package/dist/parser/service/tailordb/type-source.d.mts +5 -5
- package/dist/parser/service/tailordb/types.d.mts +4 -4
- package/dist/platform-serialize-DkiTdHOt.mjs +2 -0
- package/dist/{platform-serialize-RoRtBS0v.mjs.map → platform-serialize-DkiTdHOt.mjs.map} +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +5 -114
- package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +22 -101
- package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +9 -2
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -275
- package/dist/plugin/builtin/seed/index.d.mts +5 -0
- package/dist/plugin/builtin/seed/index.mjs +1 -3
- package/dist/plugin/builtin/seed/seed-type-processor.d.mts +4 -6
- package/dist/plugin/get-generated-table.d.mts +16 -0
- package/dist/plugin/index.d.mts +3 -2
- package/dist/plugin/index.mjs +1 -251
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/types.d.mts +32 -25
- package/dist/plugin/with-context.d.mts +4 -4
- package/dist/register-ts-hook-Drnaproy.mjs +640 -0
- package/dist/register-ts-hook-Drnaproy.mjs.map +1 -0
- package/dist/registry-HlEaGvl5.mjs +2 -0
- package/dist/{registry-BIGVUrMB.mjs.map → registry-HlEaGvl5.mjs.map} +1 -1
- package/dist/repl-editor-BG1aDOfH.mjs +2 -0
- package/dist/{repl-editor-BCozyiNq.mjs.map → repl-editor-BG1aDOfH.mjs.map} +1 -1
- package/dist/runtime/aigateway.mjs +1 -3
- package/dist/runtime/authconnection.mjs +1 -3
- package/dist/runtime/context.mjs +1 -3
- package/dist/runtime/file.d.mts +28 -28
- package/dist/runtime/file.mjs +1 -3
- package/dist/runtime/globals.mjs +1 -1
- package/dist/runtime/iconv.mjs +1 -3
- package/dist/runtime/idp.mjs +1 -3
- package/dist/runtime/index.mjs +1 -11
- package/dist/runtime/logger.mjs +1 -3
- package/dist/runtime/secretmanager.mjs +1 -3
- package/dist/runtime/types.d.mts +1 -1
- package/dist/runtime/workflow.mjs +1 -3
- package/dist/schema-Ze_dI5VX.mjs +2 -0
- package/dist/schema-Ze_dI5VX.mjs.map +1 -0
- package/dist/secret-file-C9wp_FCX.mjs +2 -0
- package/dist/{secret-file-C3J4Gy8r.mjs.map → secret-file-C9wp_FCX.mjs.map} +1 -1
- package/dist/secretmanager-5olfnI1b.mjs +2 -0
- package/dist/{secretmanager-IY4UvinW.mjs.map → secretmanager-5olfnI1b.mjs.map} +1 -1
- package/dist/secretmanager-vHQoXdQz.mjs +2 -0
- package/dist/{secretmanager-CYlpffsz.mjs.map → secretmanager-vHQoXdQz.mjs.map} +1 -1
- package/dist/seed/index.d.mts +4 -4
- package/dist/seed/index.mjs +8 -244
- package/dist/seed/index.mjs.map +1 -1
- package/dist/seed-DwqRFdqP.mjs +207 -0
- package/dist/seed-DwqRFdqP.mjs.map +1 -0
- package/dist/service-BVe9u2Rt.mjs +7 -0
- package/dist/service-BVe9u2Rt.mjs.map +1 -0
- package/dist/service-CpZELSBa.mjs +1 -0
- package/dist/service-DlgaUO4V.mjs +2 -0
- package/dist/{service-hZskxZmg.mjs.map → service-DlgaUO4V.mjs.map} +1 -1
- package/dist/service_pb-DGKCLuAs.mjs +2 -0
- package/dist/{service_pb-BEWj1pOV.mjs.map → service_pb-DGKCLuAs.mjs.map} +1 -1
- package/dist/service_pb-_aeFE-Nv.mjs +1 -0
- package/dist/telemetry-Bklv9kQY.mjs +2 -0
- package/dist/{telemetry-BRVdwh14.mjs.map → telemetry-Bklv9kQY.mjs.map} +1 -1
- package/dist/telemetry-DXHP3VVi.mjs +1 -0
- package/dist/type-source--ZNcV8RJ.mjs +2 -0
- package/dist/type-source--ZNcV8RJ.mjs.map +1 -0
- package/dist/types/aigateway.generated.d.mts +2 -2
- package/dist/types/auth.generated.d.mts +3 -3
- package/dist/types/executor.generated.d.mts +2 -2
- package/dist/types/tailordb.generated.d.mts +12 -12
- package/dist/user-agent-vdHYF3QL.mjs +2 -0
- package/dist/{user-agent-Bgsszb5I.mjs.map → user-agent-vdHYF3QL.mjs.map} +1 -1
- package/dist/utils/test/index.d.mts +4 -4
- package/dist/utils/test/index.mjs +1 -109
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.mjs +1 -41
- package/dist/vitest/environment.mjs.map +1 -1
- package/dist/vitest/index.mjs +1 -1980
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mocks/file.d.mts +8 -8
- package/dist/vitest/setup.mjs +1 -140
- package/dist/vitest/setup.mjs.map +1 -1
- package/dist/wait-point-invoker-eiP-IIux.mjs +2 -0
- package/dist/wait-point-invoker-eiP-IIux.mjs.map +1 -0
- package/dist/wait-point-registry-BrkwfyjS.mjs +2 -0
- package/dist/{wait-point-registry-TL99zotw.mjs.map → wait-point-registry-BrkwfyjS.mjs.map} +1 -1
- package/dist/workflow-Cs9ISw6j.mjs +2 -0
- package/dist/{workflow-Bamae_Yc.mjs.map → workflow-Cs9ISw6j.mjs.map} +1 -1
- package/dist/workspace_resource_pb--GeYQPXu.mjs +2 -0
- package/dist/{workspace_resource_pb-HNIL_Vfj.mjs.map → workspace_resource_pb--GeYQPXu.mjs.map} +1 -1
- package/docs/cli/application.md +3 -1
- package/docs/cli/function.md +77 -13
- package/docs/cli/setup.md +24 -14
- package/docs/cli/tailordb.md +32 -30
- package/docs/cli/workspace.md +2 -2
- package/docs/cli-reference.md +23 -22
- package/docs/configuration.md +2 -2
- package/docs/github-actions.md +10 -9
- package/docs/migration/v2.md +16 -4
- package/docs/migration/v3.md +123 -0
- package/docs/plugin/custom.md +130 -85
- package/docs/plugin/index.md +3 -3
- package/docs/quickstart.md +1 -1
- package/docs/services/aigateway.md +33 -9
- package/docs/services/executor.md +5 -1
- package/docs/services/tailordb-migration.md +68 -54
- package/docs/services/tailordb.md +7 -7
- package/docs/services/workflow.md +10 -9
- package/docs/testing.md +1 -1
- package/package.json +16 -16
- package/postinstall.mjs +1 -1
- package/dist/aigateway-DR4Kwuik.mjs +0 -9
- package/dist/application-BZfk4HKm.mjs +0 -3
- package/dist/application-F-nl107y.mjs +0 -6019
- package/dist/application-F-nl107y.mjs.map +0 -1
- package/dist/assert-DBxo8jPo.mjs +0 -9
- package/dist/authconnection-CZvi9ANm.mjs +0 -9
- package/dist/brand-Eo4pLXPJ.mjs +0 -36
- package/dist/context-DYQVYWqZ.mjs +0 -23
- package/dist/crashreport-CIIfLnoO.mjs +0 -423
- package/dist/crashreport-CINZ5dVN.mjs +0 -3
- package/dist/errors-BVb6vYGy.mjs +0 -89
- package/dist/errors-BVb6vYGy.mjs.map +0 -1
- package/dist/file-BUcmVIH2.mjs +0 -58
- package/dist/file-BUcmVIH2.mjs.map +0 -1
- package/dist/globals-B2nlxBrz.mjs +0 -126
- package/dist/iconv-QWaZh0TT.mjs +0 -38
- package/dist/idp-RA_swu-h.mjs +0 -82
- package/dist/interceptor-e33JtsC-.mjs +0 -33
- package/dist/logger-BtX0suGY.mjs +0 -48
- package/dist/logger-DSdExfor.mjs +0 -358
- package/dist/multiline-sfHpTZZK.mjs +0 -38
- package/dist/node-builtins-CmaL2Cbq.mjs +0 -36
- package/dist/package-json-8b0O9TlX.mjs +0 -17
- package/dist/package-json-Cv2Z-TqQ.mjs +0 -3
- package/dist/platform-serialize-RoRtBS0v.mjs +0 -46
- package/dist/plugin/builtin/kysely-type/index.mjs.map +0 -1
- package/dist/plugin/builtin/seed/types.d.mts +0 -2
- package/dist/plugin/get-generated-type.d.mts +0 -16
- package/dist/register-ts-hook-ClI226n2.mjs +0 -25543
- package/dist/register-ts-hook-ClI226n2.mjs.map +0 -1
- package/dist/registry-BIGVUrMB.mjs +0 -54
- package/dist/repl-editor-BCozyiNq.mjs +0 -251
- package/dist/schema--xYWRGfe.mjs +0 -639
- package/dist/schema--xYWRGfe.mjs.map +0 -1
- package/dist/secret-file-C3J4Gy8r.mjs +0 -64
- package/dist/secretmanager-CYlpffsz.mjs +0 -13
- package/dist/secretmanager-IY4UvinW.mjs +0 -131
- package/dist/seed-xqM9WIHP.mjs +0 -483
- package/dist/seed-xqM9WIHP.mjs.map +0 -1
- package/dist/service-C_WpbKHu.mjs +0 -898
- package/dist/service-C_WpbKHu.mjs.map +0 -1
- package/dist/service-D1RCdzIL.mjs +0 -3
- package/dist/service-hZskxZmg.mjs +0 -131
- package/dist/service_pb-BEWj1pOV.mjs +0 -167
- package/dist/service_pb-BjlhvK9E.mjs +0 -3
- package/dist/telemetry-BRVdwh14.mjs +0 -84
- package/dist/telemetry-CkbkeJxl.mjs +0 -3
- package/dist/type-source-DH_LH20p.mjs +0 -13
- package/dist/type-source-DH_LH20p.mjs.map +0 -1
- package/dist/user-agent-Bgsszb5I.mjs +0 -28
- package/dist/wait-point-invoker-__oE88_P.mjs +0 -148
- package/dist/wait-point-invoker-__oE88_P.mjs.map +0 -1
- package/dist/wait-point-registry-TL99zotw.mjs +0 -47
- package/dist/workflow-Bamae_Yc.mjs +0 -34
- package/dist/workspace_resource_pb-HNIL_Vfj.mjs +0 -860
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
//#region src/configure/services/workflow/registry.ts
|
|
2
|
-
const JOB_REGISTRY_KEY = Symbol.for("tailor-platform/sdk:job-registry");
|
|
3
|
-
function jobs() {
|
|
4
|
-
const g = globalThis;
|
|
5
|
-
let map = g[JOB_REGISTRY_KEY];
|
|
6
|
-
if (!map) {
|
|
7
|
-
map = /* @__PURE__ */ new Map();
|
|
8
|
-
g[JOB_REGISTRY_KEY] = map;
|
|
9
|
-
}
|
|
10
|
-
return map;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Register a job body keyed by job name. Called as a side effect by
|
|
14
|
-
* `createWorkflowJob` so `runWorkflowLocally()` can execute dependent job
|
|
15
|
-
* bodies when `globalThis.tailor.workflow.execJobFunction(name, args)` is invoked.
|
|
16
|
-
*
|
|
17
|
-
* In production builds the bundler rewrites `.start()` calls so this registry
|
|
18
|
-
* is never read; the gated write is dropped as dead code.
|
|
19
|
-
* @param name - Job name
|
|
20
|
-
* @param body - Job body function
|
|
21
|
-
*/
|
|
22
|
-
function registerJob(name, body) {
|
|
23
|
-
jobs().set(name, body);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Look up a registered job body by name.
|
|
27
|
-
* @param name - Job name
|
|
28
|
-
* @returns The registered body, or undefined when no job is registered
|
|
29
|
-
*/
|
|
30
|
-
function getRegisteredJob(name) {
|
|
31
|
-
return jobs().get(name);
|
|
32
|
-
}
|
|
33
|
-
function currentPlatformWorkflow() {
|
|
34
|
-
return globalThis.tailor?.workflow;
|
|
35
|
-
}
|
|
36
|
-
function requirePlatformWorkflow() {
|
|
37
|
-
const workflow = currentPlatformWorkflow();
|
|
38
|
-
if (!workflow) throw new Error("tailor.workflow is not available. Run tests in the `tailor-runtime` Vitest environment and use mockWorkflow(), or use runWorkflowLocally() from @tailor-platform/sdk/vitest for local workflow execution.");
|
|
39
|
-
return workflow;
|
|
40
|
-
}
|
|
41
|
-
const START_DEFAULT = "00000000-0000-4000-8000-000000000000";
|
|
42
|
-
function dispatchStartJob(name, args, options) {
|
|
43
|
-
const workflow = requirePlatformWorkflow();
|
|
44
|
-
return arguments.length >= 3 ? workflow.execJobFunction(name, args, options) : workflow.execJobFunction(name, args);
|
|
45
|
-
}
|
|
46
|
-
function dispatchStartWorkflow(name, args, options) {
|
|
47
|
-
const workflow = requirePlatformWorkflow();
|
|
48
|
-
if (arguments.length < 3) return workflow.startWorkflow(name, args);
|
|
49
|
-
return workflow.startWorkflow(name, args, options?.invoker === void 0 ? options : { authInvoker: options.invoker });
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
//#endregion
|
|
53
|
-
export { registerJob as a, getRegisteredJob as i, dispatchStartJob as n, dispatchStartWorkflow as r, START_DEFAULT as t };
|
|
54
|
-
//# sourceMappingURL=registry-BIGVUrMB.mjs.map
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import { t as assertDefined } from "./assert-DBxo8jPo.mjs";
|
|
2
|
-
import { GraphQLError, Lexer, Source, TokenKind } from "graphql";
|
|
3
|
-
import { getSegments } from "sql-highlight";
|
|
4
|
-
|
|
5
|
-
//#region src/cli/query/repl-editor.ts
|
|
6
|
-
const RESET = "\x1B[0m";
|
|
7
|
-
const BLUE = "\x1B[34m";
|
|
8
|
-
const MAGENTA = "\x1B[35m";
|
|
9
|
-
const YELLOW = "\x1B[33m";
|
|
10
|
-
const BRIGHT_GREEN = "\x1B[92m";
|
|
11
|
-
const CYAN = "\x1B[36m";
|
|
12
|
-
const BRIGHT_BLUE = "\x1B[94m";
|
|
13
|
-
const BOLD_CYAN = "\x1B[1;36m";
|
|
14
|
-
const BOLD_MAGENTA = "\x1B[1;35m";
|
|
15
|
-
const ITALIC_YELLOW = "\x1B[3;33m";
|
|
16
|
-
const GREEN = "\x1B[32m";
|
|
17
|
-
const DIM = "\x1B[90m";
|
|
18
|
-
const DIM_YELLOW = "\x1B[2;33m";
|
|
19
|
-
const SQL_STYLE_MAP = {
|
|
20
|
-
keyword: BLUE,
|
|
21
|
-
function: MAGENTA,
|
|
22
|
-
identifier: YELLOW,
|
|
23
|
-
string: BRIGHT_GREEN,
|
|
24
|
-
number: CYAN,
|
|
25
|
-
bracket: DIM_YELLOW,
|
|
26
|
-
special: DIM
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Highlight a single SQL line using the `sql-highlight` tokenizer.
|
|
30
|
-
* @param line - SQL text for a single editor line
|
|
31
|
-
* @returns ANSI-decorated line safe for terminal output
|
|
32
|
-
*/
|
|
33
|
-
function highlightSqlLine(line) {
|
|
34
|
-
const segments = getSegments(line);
|
|
35
|
-
let result = "";
|
|
36
|
-
for (const seg of segments) {
|
|
37
|
-
const style = SQL_STYLE_MAP[seg.name];
|
|
38
|
-
result += style ? style + seg.content + RESET : seg.content;
|
|
39
|
-
}
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
const GQL_KEYWORDS = /* @__PURE__ */ new Set([
|
|
43
|
-
"query",
|
|
44
|
-
"mutation",
|
|
45
|
-
"subscription",
|
|
46
|
-
"fragment",
|
|
47
|
-
"on",
|
|
48
|
-
"type",
|
|
49
|
-
"input",
|
|
50
|
-
"enum",
|
|
51
|
-
"interface",
|
|
52
|
-
"union",
|
|
53
|
-
"scalar",
|
|
54
|
-
"extend",
|
|
55
|
-
"schema",
|
|
56
|
-
"directive",
|
|
57
|
-
"implements"
|
|
58
|
-
]);
|
|
59
|
-
const GQL_DEF_KEYWORDS = /* @__PURE__ */ new Set([
|
|
60
|
-
"query",
|
|
61
|
-
"mutation",
|
|
62
|
-
"subscription",
|
|
63
|
-
"fragment"
|
|
64
|
-
]);
|
|
65
|
-
const GQL_BUILTINS = /* @__PURE__ */ new Set([
|
|
66
|
-
"true",
|
|
67
|
-
"false",
|
|
68
|
-
"null"
|
|
69
|
-
]);
|
|
70
|
-
/**
|
|
71
|
-
* Highlight a single GraphQL line using the official `graphql` Lexer. Tracks
|
|
72
|
-
* paren depth and the previous token to provide semantic-level colouring
|
|
73
|
-
* (field names vs argument names vs types).
|
|
74
|
-
* @param line - GraphQL text for a single editor line
|
|
75
|
-
* @returns ANSI-decorated line, or the input unchanged when the lexer rejects it
|
|
76
|
-
*/
|
|
77
|
-
function highlightGraphqlLine(line) {
|
|
78
|
-
if (line.trimStart().startsWith("#")) return `${DIM}${line}${RESET}`;
|
|
79
|
-
try {
|
|
80
|
-
const lexer = new Lexer(new Source(line));
|
|
81
|
-
let result = "";
|
|
82
|
-
let pos = 0;
|
|
83
|
-
let parenDepth = 0;
|
|
84
|
-
let prevKind = "";
|
|
85
|
-
let prevText = "";
|
|
86
|
-
let afterColon = false;
|
|
87
|
-
let token = lexer.advance();
|
|
88
|
-
while (token.kind !== TokenKind.EOF) {
|
|
89
|
-
if (token.start > pos) result += line.slice(pos, token.start);
|
|
90
|
-
const text = line.slice(token.start, token.end);
|
|
91
|
-
switch (token.kind) {
|
|
92
|
-
case TokenKind.NAME:
|
|
93
|
-
if (prevKind === TokenKind.DOLLAR) result += `${MAGENTA}${text}${RESET}`;
|
|
94
|
-
else if (prevKind === TokenKind.AT) result += `${BOLD_MAGENTA}${text}${RESET}`;
|
|
95
|
-
else if (GQL_BUILTINS.has(text) || GQL_KEYWORDS.has(text)) result += `${BLUE}${text}${RESET}`;
|
|
96
|
-
else if (GQL_DEF_KEYWORDS.has(prevText)) result += `${BOLD_CYAN}${text}${RESET}`;
|
|
97
|
-
else if (afterColon) result += `${CYAN}${text}${RESET}`;
|
|
98
|
-
else if (parenDepth > 0) result += `${ITALIC_YELLOW}${text}${RESET}`;
|
|
99
|
-
else result += `${BRIGHT_BLUE}${text}${RESET}`;
|
|
100
|
-
afterColon = false;
|
|
101
|
-
break;
|
|
102
|
-
case TokenKind.INT:
|
|
103
|
-
case TokenKind.FLOAT:
|
|
104
|
-
result += `${BLUE}${text}${RESET}`;
|
|
105
|
-
afterColon = false;
|
|
106
|
-
break;
|
|
107
|
-
case TokenKind.STRING:
|
|
108
|
-
case TokenKind.BLOCK_STRING:
|
|
109
|
-
result += `${GREEN}${text}${RESET}`;
|
|
110
|
-
afterColon = false;
|
|
111
|
-
break;
|
|
112
|
-
case TokenKind.DOLLAR:
|
|
113
|
-
result += `${MAGENTA}${text}${RESET}`;
|
|
114
|
-
afterColon = false;
|
|
115
|
-
break;
|
|
116
|
-
case TokenKind.AT:
|
|
117
|
-
result += `${BOLD_MAGENTA}${text}${RESET}`;
|
|
118
|
-
afterColon = false;
|
|
119
|
-
break;
|
|
120
|
-
case TokenKind.BRACE_L:
|
|
121
|
-
case TokenKind.BRACE_R:
|
|
122
|
-
result += `${YELLOW}${text}${RESET}`;
|
|
123
|
-
afterColon = false;
|
|
124
|
-
break;
|
|
125
|
-
case TokenKind.PAREN_L:
|
|
126
|
-
parenDepth += 1;
|
|
127
|
-
result += `${DIM_YELLOW}${text}${RESET}`;
|
|
128
|
-
afterColon = false;
|
|
129
|
-
break;
|
|
130
|
-
case TokenKind.PAREN_R:
|
|
131
|
-
parenDepth = Math.max(0, parenDepth - 1);
|
|
132
|
-
result += `${DIM_YELLOW}${text}${RESET}`;
|
|
133
|
-
afterColon = false;
|
|
134
|
-
break;
|
|
135
|
-
case TokenKind.BRACKET_L:
|
|
136
|
-
case TokenKind.BRACKET_R:
|
|
137
|
-
result += `${DIM_YELLOW}${text}${RESET}`;
|
|
138
|
-
afterColon = false;
|
|
139
|
-
break;
|
|
140
|
-
case TokenKind.COLON:
|
|
141
|
-
result += `${DIM}${text}${RESET}`;
|
|
142
|
-
afterColon = true;
|
|
143
|
-
break;
|
|
144
|
-
case TokenKind.BANG:
|
|
145
|
-
case TokenKind.EQUALS:
|
|
146
|
-
case TokenKind.PIPE:
|
|
147
|
-
case TokenKind.AMP:
|
|
148
|
-
case TokenKind.SPREAD:
|
|
149
|
-
result += `${DIM}${text}${RESET}`;
|
|
150
|
-
afterColon = false;
|
|
151
|
-
break;
|
|
152
|
-
default:
|
|
153
|
-
result += text;
|
|
154
|
-
afterColon = false;
|
|
155
|
-
}
|
|
156
|
-
prevKind = token.kind;
|
|
157
|
-
prevText = text;
|
|
158
|
-
pos = token.end;
|
|
159
|
-
token = lexer.advance();
|
|
160
|
-
}
|
|
161
|
-
if (pos < line.length) result += line.slice(pos);
|
|
162
|
-
return result;
|
|
163
|
-
} catch (error) {
|
|
164
|
-
if (error instanceof GraphQLError) return line;
|
|
165
|
-
throw error;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
const BRACKET_PAIRS = {
|
|
169
|
-
"(": ")",
|
|
170
|
-
"[": "]",
|
|
171
|
-
"{": "}"
|
|
172
|
-
};
|
|
173
|
-
const CLOSE_BRACKETS = new Set(Object.values(BRACKET_PAIRS));
|
|
174
|
-
/**
|
|
175
|
-
* Apply auto-close brackets and auto-indent on newline. Works for both SQL
|
|
176
|
-
* and GraphQL because both languages share the `()`, `[]`, `{}` bracket set.
|
|
177
|
-
* @param state - Editor state after the last edit
|
|
178
|
-
* @param event - Event describing the edit that just occurred
|
|
179
|
-
* @returns A new editor state to apply, or `undefined` to leave the state unchanged
|
|
180
|
-
*/
|
|
181
|
-
function replTransform(state, event) {
|
|
182
|
-
const { lines, row, col } = state;
|
|
183
|
-
if (event.type === "insert" && event.char in BRACKET_PAIRS) {
|
|
184
|
-
const close = BRACKET_PAIRS[event.char];
|
|
185
|
-
const line = assertDefined(lines[row], `line at row ${row} missing`);
|
|
186
|
-
const newLine = line.slice(0, col) + close + line.slice(col);
|
|
187
|
-
return {
|
|
188
|
-
lines: lines.with(row, newLine),
|
|
189
|
-
row,
|
|
190
|
-
col
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
if (event.type === "insert" && CLOSE_BRACKETS.has(event.char)) {
|
|
194
|
-
const line = assertDefined(lines[row], `line at row ${row} missing`);
|
|
195
|
-
if (line[col] === event.char) {
|
|
196
|
-
const newLine = line.slice(0, col) + line.slice(col + 1);
|
|
197
|
-
return {
|
|
198
|
-
lines: lines.with(row, newLine),
|
|
199
|
-
row,
|
|
200
|
-
col
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (event.type === "backspace") {
|
|
205
|
-
const line = assertDefined(lines[row], `line at row ${row} missing`);
|
|
206
|
-
const beforeCursor = line.slice(0, col);
|
|
207
|
-
if (beforeCursor.length >= 1 && /^ +$/.test(beforeCursor)) {
|
|
208
|
-
const newIndent = beforeCursor.slice(0, -1);
|
|
209
|
-
const newLine = newIndent + line.slice(col);
|
|
210
|
-
return {
|
|
211
|
-
lines: lines.with(row, newLine),
|
|
212
|
-
row,
|
|
213
|
-
col: newIndent.length
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (event.type === "newline" && row > 0) {
|
|
218
|
-
const prevLine = assertDefined(lines[row - 1], `line at row ${row - 1} missing`);
|
|
219
|
-
const baseIndent = prevLine.match(/^(\s*)/)?.[1] ?? "";
|
|
220
|
-
const endsWithOpen = /[{([]$/.test(prevLine.trimEnd());
|
|
221
|
-
const currentLine = assertDefined(lines[row], `line at row ${row} missing`);
|
|
222
|
-
const startsWithClose = /^[}\])]/.test(currentLine.trimStart());
|
|
223
|
-
if (endsWithOpen && startsWithClose) {
|
|
224
|
-
const innerIndent = baseIndent + " ";
|
|
225
|
-
return {
|
|
226
|
-
lines: lines.with(row, innerIndent).toSpliced(row + 1, 0, baseIndent + currentLine.trimStart()),
|
|
227
|
-
row,
|
|
228
|
-
col: innerIndent.length
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
if (endsWithOpen) {
|
|
232
|
-
const openChar = prevLine.trimEnd().slice(-1);
|
|
233
|
-
const closeChar = BRACKET_PAIRS[openChar] ?? "}";
|
|
234
|
-
const indent = baseIndent + " ";
|
|
235
|
-
return {
|
|
236
|
-
lines: lines.with(row, indent + currentLine).toSpliced(row + 1, 0, baseIndent + closeChar),
|
|
237
|
-
row,
|
|
238
|
-
col: indent.length
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
if (baseIndent && col === 0) return {
|
|
242
|
-
lines: lines.with(row, baseIndent + currentLine),
|
|
243
|
-
row,
|
|
244
|
-
col: baseIndent.length
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
//#endregion
|
|
250
|
-
export { highlightGraphqlLine, highlightSqlLine, replTransform };
|
|
251
|
-
//# sourceMappingURL=repl-editor-BCozyiNq.mjs.map
|