@bluestep-systems/b6p-core 0.9.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +274 -24
- package/dist/B6PCore.d.ts +13 -0
- package/dist/B6PCore.js +61 -1
- package/dist/B6PCore.js.map +1 -1
- package/dist/B6PUri.d.ts +6 -8
- package/dist/B6PUri.js +6 -8
- package/dist/B6PUri.js.map +1 -1
- package/dist/Err.d.ts +434 -0
- package/dist/Err.js +582 -0
- package/dist/Err.js.map +1 -1
- package/dist/auth/BearerAuthProvider.d.ts +32 -0
- package/dist/auth/BearerAuthProvider.js +49 -0
- package/dist/auth/BearerAuthProvider.js.map +1 -1
- package/dist/cache/OrgCache.js.map +1 -1
- package/dist/cache/ScriptMetaDataStore.js.map +1 -1
- package/dist/constants/ApiEndpoints.d.ts +1 -0
- package/dist/constants/ApiEndpoints.js +1 -0
- package/dist/constants/ApiEndpoints.js.map +1 -1
- package/dist/constants/AuthTypes.js.map +1 -1
- package/dist/constants/BlueHQ.js.map +1 -1
- package/dist/constants/CryptoAlgorithms.js.map +1 -1
- package/dist/constants/ExtensionConfig.js.map +1 -1
- package/dist/constants/FileExtensions.js.map +1 -1
- package/dist/constants/FolderNames.js.map +1 -1
- package/dist/constants/Gateway.d.ts +71 -0
- package/dist/constants/Gateway.js +79 -0
- package/dist/constants/Gateway.js.map +1 -0
- package/dist/constants/GitHubUrls.js.map +1 -1
- package/dist/constants/Http.js.map +1 -1
- package/dist/constants/MimeTypes.js.map +1 -1
- package/dist/constants/Numerical.js.map +1 -1
- package/dist/constants/OutputChannels.js.map +1 -1
- package/dist/constants/SettingsKeys.d.ts +5 -0
- package/dist/constants/SettingsKeys.js +5 -0
- package/dist/constants/SettingsKeys.js.map +1 -1
- package/dist/constants/SpecialFiles.js.map +1 -1
- package/dist/constants/WebDAVElements.js.map +1 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +3 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/data/DownstairsPathParser.js.map +1 -1
- package/dist/data/GlobMatcher.js.map +1 -1
- package/dist/data/IdUtility.js.map +1 -1
- package/dist/data/OrgWorker.js.map +1 -1
- package/dist/data/ScriptKey.js.map +1 -1
- package/dist/data/ScriptUrlParser.js.map +1 -1
- package/dist/data/ServerVersion.d.ts +76 -0
- package/dist/data/ServerVersion.js +111 -0
- package/dist/data/ServerVersion.js.map +1 -0
- package/dist/data/index.d.ts +2 -0
- package/dist/data/index.js +7 -1
- package/dist/data/index.js.map +1 -1
- package/dist/gateway/GatewayClient.d.ts +147 -0
- package/dist/gateway/GatewayClient.js +395 -0
- package/dist/gateway/GatewayClient.js.map +1 -0
- package/dist/gateway/GatewayContext.d.ts +43 -0
- package/dist/gateway/GatewayContext.js +3 -0
- package/dist/gateway/GatewayContext.js.map +1 -0
- package/dist/gateway/GatewayGit.d.ts +291 -0
- package/dist/gateway/GatewayGit.js +731 -0
- package/dist/gateway/GatewayGit.js.map +1 -0
- package/dist/gateway/GatewayKb.d.ts +173 -0
- package/dist/gateway/GatewayKb.js +354 -0
- package/dist/gateway/GatewayKb.js.map +1 -0
- package/dist/gateway/GatewayMarketplace.d.ts +116 -0
- package/dist/gateway/GatewayMarketplace.js +278 -0
- package/dist/gateway/GatewayMarketplace.js.map +1 -0
- package/dist/gateway/GatewayService.d.ts +47 -0
- package/dist/gateway/GatewayService.js +54 -0
- package/dist/gateway/GatewayService.js.map +1 -0
- package/dist/gateway/GatewayToken.d.ts +18 -0
- package/dist/gateway/GatewayToken.js +43 -0
- package/dist/gateway/GatewayToken.js.map +1 -0
- package/dist/gateway/GatewayTokenService.d.ts +101 -0
- package/dist/gateway/GatewayTokenService.js +465 -0
- package/dist/gateway/GatewayTokenService.js.map +1 -0
- package/dist/index.d.ts +27 -9
- package/dist/index.js +36 -7
- package/dist/index.js.map +1 -1
- package/dist/network/HttpClient.js.map +1 -1
- package/dist/network/HttpClientProvider.js.map +1 -1
- package/dist/network/StatusCodes.js.map +1 -1
- package/dist/persistence/PersistablePseudoMap.js.map +1 -1
- package/dist/persistence/PersistenceKeys.js.map +1 -1
- package/dist/persistence/PrivatePersistanceMap.js.map +1 -1
- package/dist/persistence/PseudoMap.js.map +1 -1
- package/dist/persistence/PublicPersistanceMap.js.map +1 -1
- package/dist/persistence/Serializable.js.map +1 -1
- package/dist/persistence/SharedFilePersistence.d.ts +22 -0
- package/dist/persistence/SharedFilePersistence.js +65 -14
- package/dist/persistence/SharedFilePersistence.js.map +1 -1
- package/dist/persistence/TypedMap.js.map +1 -1
- package/dist/persistence/TypedPersistable.js.map +1 -1
- package/dist/persistence/TypedPrivatePersistable.js.map +1 -1
- package/dist/persistence/dirLockdown.js.map +1 -1
- package/dist/providers.d.ts +36 -19
- package/dist/schema/SchemaContext.d.ts +10 -0
- package/dist/schema/SchemaContext.js +3 -0
- package/dist/schema/SchemaContext.js.map +1 -0
- package/dist/schema/SchemaService.d.ts +99 -0
- package/dist/schema/SchemaService.js +225 -0
- package/dist/schema/SchemaService.js.map +1 -0
- package/dist/script/GitIdentity.js.map +1 -1
- package/dist/script/GitSync.d.ts +78 -11
- package/dist/script/GitSync.js +84 -17
- package/dist/script/GitSync.js.map +1 -1
- package/dist/script/ScriptContext.d.ts +1 -8
- package/dist/script/ScriptFactory.d.ts +1 -2
- package/dist/script/ScriptFactory.js +1 -2
- package/dist/script/ScriptFactory.js.map +1 -1
- package/dist/script/ScriptFile.js.map +1 -1
- package/dist/script/ScriptFolder.js.map +1 -1
- package/dist/script/ScriptNode.js.map +1 -1
- package/dist/script/ScriptRoot.d.ts +0 -63
- package/dist/script/ScriptRoot.js +0 -178
- package/dist/script/ScriptRoot.js.map +1 -1
- package/dist/script/ScriptService.d.ts +45 -11
- package/dist/script/ScriptService.js +44 -6
- package/dist/script/ScriptService.js.map +1 -1
- package/dist/script/ServerCompile.d.ts +35 -0
- package/dist/script/ServerCompile.js +40 -0
- package/dist/script/ServerCompile.js.map +1 -0
- package/dist/script/TsConfig.d.ts +2 -2
- package/dist/script/TsConfig.js +3 -3
- package/dist/script/TsConfig.js.map +1 -1
- package/dist/script/push.d.ts +117 -77
- package/dist/script/push.js +151 -170
- package/dist/script/push.js.map +1 -1
- package/dist/session/SessionManager.js.map +1 -1
- package/dist/testing/FakeGateway.d.ts +280 -0
- package/dist/testing/FakeGateway.js +627 -0
- package/dist/testing/FakeGateway.js.map +1 -0
- package/dist/testing/MockFileSystem.js.map +1 -1
- package/dist/types.d.ts +534 -0
- package/dist/update/UpdateService.js.map +1 -1
- package/package.json +8 -7
- package/dist/script/ScriptTranspiler.d.ts +0 -183
- package/dist/script/ScriptTranspiler.js +0 -425
- package/dist/script/ScriptTranspiler.js.map +0 -1
- package/dist/script/TsLibResolver.d.ts +0 -60
- package/dist/script/TsLibResolver.js +0 -134
- package/dist/script/TsLibResolver.js.map +0 -1
package/dist/providers.d.ts
CHANGED
|
@@ -132,6 +132,42 @@ export interface AuthProvider<T extends AuthParams> {
|
|
|
132
132
|
/** Whether credentials are currently stored. Never prompts. */
|
|
133
133
|
hasCredentials(): Promise<boolean>;
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Where the gateway client gets the global user's `b6pt_` access token. The client asks on every
|
|
137
|
+
* request and sends what it gets as `Authorization: Bearer <token>`, with no session bootstrap.
|
|
138
|
+
*
|
|
139
|
+
* `B6PCore` backs it with the token the bearer auth provider already stores (the same token that
|
|
140
|
+
* bootstraps the web session). It is an interface so the client and its specs depend only on
|
|
141
|
+
* "something that yields the token", not on where it is kept.
|
|
142
|
+
* @lastreviewed null
|
|
143
|
+
*/
|
|
144
|
+
export interface GatewayTokenSource {
|
|
145
|
+
/**
|
|
146
|
+
* The token, or `undefined` when there is none. Never prompts: a missing token surfaces as a
|
|
147
|
+
* typed error from the client, and the consumer decides how to ask for one.
|
|
148
|
+
* @lastreviewed null
|
|
149
|
+
*/
|
|
150
|
+
token(): Promise<string | undefined>;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Where a rotated replacement of the stored `b6pt_` token is written. There is still ONE stored
|
|
154
|
+
* token: this replaces it in place and never adds a second.
|
|
155
|
+
*
|
|
156
|
+
* `B6PCore` backs it with {@link BearerAuthProvider.replaceStoredToken}. It is the narrowest write
|
|
157
|
+
* the token-management service needs, and the only one: it cannot clear, prompt, or store a token
|
|
158
|
+
* that is not replacing the one it was rotated from.
|
|
159
|
+
* @lastreviewed null
|
|
160
|
+
*/
|
|
161
|
+
export interface GatewayTokenStore {
|
|
162
|
+
/**
|
|
163
|
+
* Store `next` in place of `expected`. Rejects, leaving the stored token as it was, when the
|
|
164
|
+
* stored token is no longer `expected` (something else replaced it meanwhile) or cannot be
|
|
165
|
+
* written. The check is a compare-then-write, not atomic across processes. Neither value is
|
|
166
|
+
* ever logged or put in an error message.
|
|
167
|
+
* @lastreviewed null
|
|
168
|
+
*/
|
|
169
|
+
replace(expected: string, next: string): Promise<void>;
|
|
170
|
+
}
|
|
135
171
|
export interface Logger {
|
|
136
172
|
info(...args: unknown[]): void;
|
|
137
173
|
warn(...args: unknown[]): void;
|
|
@@ -209,25 +245,6 @@ export interface B6PProviders {
|
|
|
209
245
|
* fetch that adds proxy/cookie handling.
|
|
210
246
|
*/
|
|
211
247
|
fetchFn?: (url: string | URL, init?: RequestInit) => Promise<Response>;
|
|
212
|
-
/**
|
|
213
|
-
* Optional directories that contain TypeScript's default library declaration
|
|
214
|
-
* files (`lib.d.ts`, `lib.es2022.d.ts`, `lib.dom.d.ts`, ...). Used only by the
|
|
215
|
-
* local transpile step that snapshot pushes run.
|
|
216
|
-
*
|
|
217
|
-
* WHY THIS EXISTS: b6p-core is bundled into the consumer (the CLI's single
|
|
218
|
-
* `dist/cli.js` and its SEA binary). TypeScript's default host resolves the
|
|
219
|
-
* standard library via `getDefaultLibLocation()` = `dirname(__filename)`. Once
|
|
220
|
-
* bundled, `__filename` is the bundle path — where no `lib.*.d.ts` live — so
|
|
221
|
-
* every compile fails with "File 'lib.esnext.d.ts' not found" cascading into
|
|
222
|
-
* "Cannot find global type 'Array'". Because that resolution is unreliable
|
|
223
|
-
* when bundled, the consumer should pass the directory it ships or extracts
|
|
224
|
-
* these files to:
|
|
225
|
-
* - npm bundle: a `lib/` copied next to the bundle (e.g. by esbuild).
|
|
226
|
-
* - SEA binary: a temp dir the binary extracts its embedded libs into.
|
|
227
|
-
* These are searched before the project-local `node_modules/typescript/lib`.
|
|
228
|
-
* @lastreviewed null
|
|
229
|
-
*/
|
|
230
|
-
typescriptLibDirs?: readonly string[];
|
|
231
248
|
/**
|
|
232
249
|
* Optional Node-style file system (with `.promises`) the script git working trees live on. Defaults to `node:fs`.
|
|
233
250
|
* Pass one only to run against something other than the real disk the `fs` provider also reads (tests).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PlatformContext } from "../PlatformContext";
|
|
2
|
+
/**
|
|
3
|
+
* The dependency bundle of the schema subsystem ({@link SchemaService}): the shared {@link PlatformContext} and
|
|
4
|
+
* nothing more. The service talks to an org's `/gql` through `sessionManager` (the same CSRF-managed path script code
|
|
5
|
+
* uses) and reports through `logger`; it reads no script store or cache, so there is nothing to add to the shared half.
|
|
6
|
+
* It is a bundle that is held, never implemented; see {@link PlatformContext}.
|
|
7
|
+
* @lastreviewed null
|
|
8
|
+
*/
|
|
9
|
+
export interface SchemaContext extends PlatformContext {
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaContext.js","sourceRoot":"","sources":["../../src/schema/SchemaContext.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { SchemaApplyResult, SchemaRecipeName, SchemaRecipeResult, SchemaTestResult } from "../types";
|
|
2
|
+
import type { SchemaContext } from "./SchemaContext";
|
|
3
|
+
/**
|
|
4
|
+
* Options of {@link SchemaService.generate}.
|
|
5
|
+
* @lastreviewed null
|
|
6
|
+
*/
|
|
7
|
+
export interface SchemaGenerateOptions {
|
|
8
|
+
/** Declare every object of a supported kind the named ones reference too; default `true` (the server's). @lastreviewed null */
|
|
9
|
+
closure?: boolean;
|
|
10
|
+
/** Generate a manifest holding no key, for applying in another tenant; default `false` (the server's). @lastreviewed null */
|
|
11
|
+
portable?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Options of {@link SchemaService.test}.
|
|
15
|
+
* @lastreviewed null
|
|
16
|
+
*/
|
|
17
|
+
export interface SchemaTestOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Also report same-display-name collisions within a kind as warnings. Sent only when `true`, so a server that predates
|
|
20
|
+
* the argument keeps working; a server that rejects it throws `Err.SchemaServerTooOldError`.
|
|
21
|
+
* @lastreviewed null
|
|
22
|
+
*/
|
|
23
|
+
verbose?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* What {@link SchemaService.testThenApply} did.
|
|
27
|
+
* @lastreviewed null
|
|
28
|
+
*/
|
|
29
|
+
export interface SchemaTestThenApplyResult {
|
|
30
|
+
/** The dry run. @lastreviewed null */
|
|
31
|
+
test: SchemaTestResult;
|
|
32
|
+
/** The caller was shown a passing test and answered no, so nothing was applied. @lastreviewed null */
|
|
33
|
+
declined: boolean;
|
|
34
|
+
/** The apply's answer; `null` when the test did not pass (no key) or the caller declined. @lastreviewed null */
|
|
35
|
+
apply: SchemaApplyResult | null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The schema subsystem, `core.schema`: generate, test and apply declarative manifests against one org. Every operation
|
|
39
|
+
* is reserved to super users on the server (`Err.SchemaForbiddenError` otherwise). Requests go to the org's `/gql`
|
|
40
|
+
* through the session manager, the same CSRF-managed path script code uses.
|
|
41
|
+
*
|
|
42
|
+
* Each method takes `org`: any URL on the org (its origin is used), the way other per-org calls take one.
|
|
43
|
+
* @lastreviewed null
|
|
44
|
+
*/
|
|
45
|
+
export declare class SchemaService {
|
|
46
|
+
private readonly ctx;
|
|
47
|
+
constructor(ctx: SchemaContext);
|
|
48
|
+
/**
|
|
49
|
+
* The manifest describing the named objects as they stand now (GraphQL `generateSchema`).
|
|
50
|
+
* @param org Any URL on the org; its origin is used
|
|
51
|
+
* @param topIds Ids of the objects to describe
|
|
52
|
+
* @returns The manifest, a YAML stream
|
|
53
|
+
* @throws Err.SchemaForbiddenError when the caller is not a super user
|
|
54
|
+
* @lastreviewed null
|
|
55
|
+
*/
|
|
56
|
+
generate(org: string | URL, topIds: readonly string[], options?: SchemaGenerateOptions): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Runs a recipe: an audit of the org stated as a manifest, with what it met (GraphQL `schemaRecipe`). Writes nothing.
|
|
59
|
+
* @throws Err.SchemaForbiddenError when the caller is not a super user
|
|
60
|
+
* @lastreviewed null
|
|
61
|
+
*/
|
|
62
|
+
recipe(org: string | URL, name: SchemaRecipeName): Promise<SchemaRecipeResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Evaluates a manifest against the org as the caller, writing nothing (GraphQL `testSchema`). When every stage
|
|
65
|
+
* passes the result carries the key {@link apply} needs. `verbose` is sent only when asked for.
|
|
66
|
+
* @throws Err.SchemaForbiddenError when the caller is not a super user
|
|
67
|
+
* @throws Err.SchemaServerTooOldError when `verbose` is asked for and the server does not know the argument
|
|
68
|
+
* @lastreviewed null
|
|
69
|
+
*/
|
|
70
|
+
test(org: string | URL, manifest: string, options?: SchemaTestOptions): Promise<SchemaTestResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Applies the plan a {@link test} approved (GraphQL `applySchema`): the manifest string that was tested, byte for
|
|
73
|
+
* byte, and its key. The key is spent by the call whatever its outcome.
|
|
74
|
+
*
|
|
75
|
+
* The request is not retried: a retry after a lost answer would find the key spent and report `KEY_INVALID` for an
|
|
76
|
+
* apply that may have committed. A transport failure here means the outcome is unknown; a fresh {@link test} then
|
|
77
|
+
* plans to no change if the apply went through.
|
|
78
|
+
* @throws Err.SchemaForbiddenError when the caller is not a super user
|
|
79
|
+
* @lastreviewed null
|
|
80
|
+
*/
|
|
81
|
+
apply(org: string | URL, manifest: string, schemaMutationKey: string): Promise<SchemaApplyResult>;
|
|
82
|
+
/**
|
|
83
|
+
* {@link test}, hand the result to `confirm`, and on a yes {@link apply} the same manifest string with the key the
|
|
84
|
+
* test minted. Keeps "same bytes, same key" in one place. `confirm` is asked only when the test passed.
|
|
85
|
+
* @lastreviewed null
|
|
86
|
+
*/
|
|
87
|
+
testThenApply(org: string | URL, manifest: string, confirm: (result: SchemaTestResult) => Promise<boolean>, options?: SchemaTestOptions): Promise<SchemaTestThenApplyResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Posts one operation to the org's `/gql` and returns its `data`.
|
|
90
|
+
* @param operation The schema operation's name, for the error that names it
|
|
91
|
+
* @param retries Passed to the session manager's retrying fetch; `0` for a request that must not be repeated
|
|
92
|
+
* @throws Err.SchemaForbiddenError on `FORBIDDEN`
|
|
93
|
+
* @throws Err.SchemaServerTooOldError when the server's validation rejects a schema operation or `verbose`
|
|
94
|
+
* @throws Err.GraphQLError on any other GraphQL error
|
|
95
|
+
* @throws Err.GraphQLFetchError on a non-OK answer that is no GraphQL answer, or one with no data
|
|
96
|
+
* @lastreviewed null
|
|
97
|
+
*/
|
|
98
|
+
private post;
|
|
99
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaService = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const Err_1 = require("../Err");
|
|
6
|
+
/**
|
|
7
|
+
* The GraphQL selection of a {@link SchemaApplyRefusal}.
|
|
8
|
+
* @lastreviewed null
|
|
9
|
+
*/
|
|
10
|
+
const APPLY_REFUSAL_FIELDS = "code element detail";
|
|
11
|
+
/**
|
|
12
|
+
* The GraphQL selection of a {@link SchemaTestResult}: every field.
|
|
13
|
+
* @lastreviewed null
|
|
14
|
+
*/
|
|
15
|
+
const TEST_RESULT_FIELDS = `
|
|
16
|
+
passed
|
|
17
|
+
failedAt
|
|
18
|
+
actions {
|
|
19
|
+
element
|
|
20
|
+
action
|
|
21
|
+
objectId
|
|
22
|
+
spec
|
|
23
|
+
deltas { path kind from to livePositions }
|
|
24
|
+
reasons { code detail }
|
|
25
|
+
}
|
|
26
|
+
refusals {
|
|
27
|
+
stage
|
|
28
|
+
code
|
|
29
|
+
locus
|
|
30
|
+
detail
|
|
31
|
+
hits { objectId live }
|
|
32
|
+
}
|
|
33
|
+
schemaMutationKey
|
|
34
|
+
refusal { ${APPLY_REFUSAL_FIELDS} }
|
|
35
|
+
warnings { element detail }
|
|
36
|
+
`;
|
|
37
|
+
/**
|
|
38
|
+
* The GraphQL selection of a {@link SchemaApplyResult}: every field.
|
|
39
|
+
* @lastreviewed null
|
|
40
|
+
*/
|
|
41
|
+
const APPLY_RESULT_FIELDS = `
|
|
42
|
+
applied
|
|
43
|
+
objects { element objectId }
|
|
44
|
+
refusal { ${APPLY_REFUSAL_FIELDS} }
|
|
45
|
+
failedAt
|
|
46
|
+
historyCommit
|
|
47
|
+
`;
|
|
48
|
+
/**
|
|
49
|
+
* The GraphQL selection of a {@link SchemaRecipeResult}: every field.
|
|
50
|
+
* @lastreviewed null
|
|
51
|
+
*/
|
|
52
|
+
const RECIPE_RESULT_FIELDS = `
|
|
53
|
+
manifest
|
|
54
|
+
findings { code severity subjectId fieldId formId detail }
|
|
55
|
+
`;
|
|
56
|
+
/**
|
|
57
|
+
* The schema operation names, which a validation error naming one (or `verbose`) means the server does not know.
|
|
58
|
+
* @lastreviewed null
|
|
59
|
+
*/
|
|
60
|
+
const SCHEMA_FEATURE_NAME = /\b(generateSchema|schemaRecipe|testSchema|applySchema|verbose)\b/;
|
|
61
|
+
/**
|
|
62
|
+
* The schema subsystem, `core.schema`: generate, test and apply declarative manifests against one org. Every operation
|
|
63
|
+
* is reserved to super users on the server (`Err.SchemaForbiddenError` otherwise). Requests go to the org's `/gql`
|
|
64
|
+
* through the session manager, the same CSRF-managed path script code uses.
|
|
65
|
+
*
|
|
66
|
+
* Each method takes `org`: any URL on the org (its origin is used), the way other per-org calls take one.
|
|
67
|
+
* @lastreviewed null
|
|
68
|
+
*/
|
|
69
|
+
class SchemaService {
|
|
70
|
+
ctx;
|
|
71
|
+
constructor(ctx) {
|
|
72
|
+
this.ctx = ctx;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The manifest describing the named objects as they stand now (GraphQL `generateSchema`).
|
|
76
|
+
* @param org Any URL on the org; its origin is used
|
|
77
|
+
* @param topIds Ids of the objects to describe
|
|
78
|
+
* @returns The manifest, a YAML stream
|
|
79
|
+
* @throws Err.SchemaForbiddenError when the caller is not a super user
|
|
80
|
+
* @lastreviewed null
|
|
81
|
+
*/
|
|
82
|
+
async generate(org, topIds, options = {}) {
|
|
83
|
+
const data = await this.post(org, "generateSchema", `query GenerateSchema($topIds: [ID!]!, $closure: Boolean!, $portable: Boolean!) {
|
|
84
|
+
generateSchema(topIds: $topIds, closure: $closure, portable: $portable)
|
|
85
|
+
}`, { topIds: [...topIds], closure: options.closure ?? true, portable: options.portable ?? false });
|
|
86
|
+
return data.generateSchema;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Runs a recipe: an audit of the org stated as a manifest, with what it met (GraphQL `schemaRecipe`). Writes nothing.
|
|
90
|
+
* @throws Err.SchemaForbiddenError when the caller is not a super user
|
|
91
|
+
* @lastreviewed null
|
|
92
|
+
*/
|
|
93
|
+
async recipe(org, name) {
|
|
94
|
+
const data = await this.post(org, "schemaRecipe", `query SchemaRecipe($name: SchemaRecipeName!) { schemaRecipe(name: $name) { ${RECIPE_RESULT_FIELDS} } }`, { name });
|
|
95
|
+
return data.schemaRecipe;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Evaluates a manifest against the org as the caller, writing nothing (GraphQL `testSchema`). When every stage
|
|
99
|
+
* passes the result carries the key {@link apply} needs. `verbose` is sent only when asked for.
|
|
100
|
+
* @throws Err.SchemaForbiddenError when the caller is not a super user
|
|
101
|
+
* @throws Err.SchemaServerTooOldError when `verbose` is asked for and the server does not know the argument
|
|
102
|
+
* @lastreviewed null
|
|
103
|
+
*/
|
|
104
|
+
async test(org, manifest, options = {}) {
|
|
105
|
+
const verbose = options.verbose === true;
|
|
106
|
+
const data = await this.post(org, "testSchema", verbose
|
|
107
|
+
? `mutation TestSchema($manifest: String!, $verbose: Boolean!) {
|
|
108
|
+
testSchema(manifest: $manifest, verbose: $verbose) { ${TEST_RESULT_FIELDS} }
|
|
109
|
+
}`
|
|
110
|
+
: `mutation TestSchema($manifest: String!) { testSchema(manifest: $manifest) { ${TEST_RESULT_FIELDS} } }`, verbose ? { manifest, verbose } : { manifest });
|
|
111
|
+
return data.testSchema;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Applies the plan a {@link test} approved (GraphQL `applySchema`): the manifest string that was tested, byte for
|
|
115
|
+
* byte, and its key. The key is spent by the call whatever its outcome.
|
|
116
|
+
*
|
|
117
|
+
* The request is not retried: a retry after a lost answer would find the key spent and report `KEY_INVALID` for an
|
|
118
|
+
* apply that may have committed. A transport failure here means the outcome is unknown; a fresh {@link test} then
|
|
119
|
+
* plans to no change if the apply went through.
|
|
120
|
+
* @throws Err.SchemaForbiddenError when the caller is not a super user
|
|
121
|
+
* @lastreviewed null
|
|
122
|
+
*/
|
|
123
|
+
async apply(org, manifest, schemaMutationKey) {
|
|
124
|
+
const data = await this.post(org, "applySchema", `mutation ApplySchema($manifest: String!, $key: ID!) {
|
|
125
|
+
applySchema(manifest: $manifest, schemaMutationKey: $key) { ${APPLY_RESULT_FIELDS} }
|
|
126
|
+
}`, { manifest, key: schemaMutationKey }, 0);
|
|
127
|
+
return data.applySchema;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* {@link test}, hand the result to `confirm`, and on a yes {@link apply} the same manifest string with the key the
|
|
131
|
+
* test minted. Keeps "same bytes, same key" in one place. `confirm` is asked only when the test passed.
|
|
132
|
+
* @lastreviewed null
|
|
133
|
+
*/
|
|
134
|
+
async testThenApply(org, manifest, confirm, options = {}) {
|
|
135
|
+
const test = await this.test(org, manifest, options);
|
|
136
|
+
if (!test.passed || test.schemaMutationKey === null) {
|
|
137
|
+
return { test, declined: false, apply: null };
|
|
138
|
+
}
|
|
139
|
+
if (!(await confirm(test))) {
|
|
140
|
+
return { test, declined: true, apply: null };
|
|
141
|
+
}
|
|
142
|
+
return { test, declined: false, apply: await this.apply(org, manifest, test.schemaMutationKey) };
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Posts one operation to the org's `/gql` and returns its `data`.
|
|
146
|
+
* @param operation The schema operation's name, for the error that names it
|
|
147
|
+
* @param retries Passed to the session manager's retrying fetch; `0` for a request that must not be repeated
|
|
148
|
+
* @throws Err.SchemaForbiddenError on `FORBIDDEN`
|
|
149
|
+
* @throws Err.SchemaServerTooOldError when the server's validation rejects a schema operation or `verbose`
|
|
150
|
+
* @throws Err.GraphQLError on any other GraphQL error
|
|
151
|
+
* @throws Err.GraphQLFetchError on a non-OK answer that is no GraphQL answer, or one with no data
|
|
152
|
+
* @lastreviewed null
|
|
153
|
+
*/
|
|
154
|
+
async post(org, operation, query, variables, retries) {
|
|
155
|
+
const url = new URL(org);
|
|
156
|
+
url.pathname = constants_1.ApiEndpoints.GQL;
|
|
157
|
+
url.search = "";
|
|
158
|
+
url.hash = "";
|
|
159
|
+
if (retries === 0) {
|
|
160
|
+
// A request that must not be repeated cannot lean on csrfFetch's retry to recover a stale session: csrfFetch
|
|
161
|
+
// keeps an expired session object across its own login. Fetching the CSRF token first logs in when the session
|
|
162
|
+
// is expired, so csrfFetch then finds a live session and its one POST carries a matching token and cookie.
|
|
163
|
+
const warm = new URL(url);
|
|
164
|
+
warm.pathname = constants_1.ApiEndpoints.CSRF_TOKEN;
|
|
165
|
+
await this.ctx.sessionManager.fetch(warm);
|
|
166
|
+
}
|
|
167
|
+
const res = await this.ctx.sessionManager.csrfFetch(url, {
|
|
168
|
+
method: constants_1.Http.Methods.POST,
|
|
169
|
+
headers: { [constants_1.Http.Headers.CONTENT_TYPE]: constants_1.MimeTypes.APPLICATION_JSON },
|
|
170
|
+
body: JSON.stringify({ query, variables, operationName: operationNameOf(query) }),
|
|
171
|
+
}, retries);
|
|
172
|
+
const text = await res.text();
|
|
173
|
+
let body;
|
|
174
|
+
try {
|
|
175
|
+
const parsed = JSON.parse(text);
|
|
176
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
177
|
+
throw new Error("not a GraphQL response object");
|
|
178
|
+
}
|
|
179
|
+
body = parsed;
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
throw new Err_1.Err.GraphQLFetchError(`${operation}: HTTP ${res.status} with no JSON body: ${text.substring(0, 500)}`);
|
|
183
|
+
}
|
|
184
|
+
if (Array.isArray(body.errors) && body.errors.length > 0) {
|
|
185
|
+
if (body.errors.some((e) => codeOf(e) === "FORBIDDEN")) {
|
|
186
|
+
throw new Err_1.Err.SchemaForbiddenError(operation);
|
|
187
|
+
}
|
|
188
|
+
const tooOld = body.errors.find((e) => codeOf(e) === "ValidationError" && SCHEMA_FEATURE_NAME.test(e.message ?? ""));
|
|
189
|
+
if (tooOld !== undefined) {
|
|
190
|
+
const feature = /\bverbose\b/.test(tooOld.message ?? "") ? "testSchema's verbose argument" : operation;
|
|
191
|
+
throw new Err_1.Err.SchemaServerTooOldError(feature, tooOld.message ?? "");
|
|
192
|
+
}
|
|
193
|
+
throw new Err_1.Err.GraphQLError(body.errors);
|
|
194
|
+
}
|
|
195
|
+
const data = body.data;
|
|
196
|
+
if (!res.ok ||
|
|
197
|
+
typeof data !== "object" ||
|
|
198
|
+
data === null ||
|
|
199
|
+
data[operation] === undefined ||
|
|
200
|
+
data[operation] === null) {
|
|
201
|
+
throw new Err_1.Err.GraphQLFetchError(`${operation}: HTTP ${res.status} ${res.statusText} with no ${operation} answer`);
|
|
202
|
+
}
|
|
203
|
+
return data;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
exports.SchemaService = SchemaService;
|
|
207
|
+
/**
|
|
208
|
+
* The code of a GraphQL error: the server's `extensions.code`, else graphql-java's `extensions.classification`.
|
|
209
|
+
* @lastreviewed null
|
|
210
|
+
*/
|
|
211
|
+
function codeOf(error) {
|
|
212
|
+
return error.extensions?.code ?? error.extensions?.classification;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The operation name a query document declares (`query Name`, `mutation Name`).
|
|
216
|
+
* @lastreviewed null
|
|
217
|
+
*/
|
|
218
|
+
function operationNameOf(query) {
|
|
219
|
+
const match = /^\s*(?:query|mutation)\s+(\w+)/.exec(query);
|
|
220
|
+
if (match === null) {
|
|
221
|
+
throw new Error("schema operation without a name");
|
|
222
|
+
}
|
|
223
|
+
return match[1];
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=SchemaService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaService.js","sourceRoot":"","sources":["../../src/schema/SchemaService.ts"],"names":[],"mappings":";;;AAAA,4CAA6D;AAC7D,gCAA6B;AAyC7B;;;GAGG;AACH,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAEnD;;;GAGG;AACH,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;cAmBb,oBAAoB;;CAEjC,CAAC;AAEF;;;GAGG;AACH,MAAM,mBAAmB,GAAG;;;cAGd,oBAAoB;;;CAGjC,CAAC;AAEF;;;GAGG;AACH,MAAM,oBAAoB,GAAG;;;CAG5B,CAAC;AAEF;;;GAGG;AACH,MAAM,mBAAmB,GAAG,kEAAkE,CAAC;AAoB/F;;;;;;;GAOG;AACH;IAC+B,GAAG;IAAhC,YAA6B,GAAkB;mBAAlB,GAAG;IAAkB,CAAC;IAEnD;;;;;;;OAOG;IACH,KAAK,CAAC,QAAQ,CAAC,GAAiB,EAAE,MAAyB,EAAE,OAAO,GAA0B,EAAE;QAC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AI,CAAC;IACd,CAAC;CACF;;AAED;;;GAGG;AACH,SAAS,MAAM,CAAC,KAAwB;IACtC,OAAO,KAAK,CAAC,UAAU,EAAE,IAAI,IAAI,KAAK,CAAC,UAAU,EAAE,cAAc,CAAC;AACpE,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,KAAa;IACpC,MAAM,KAAK,GAAG,gCAAgC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3D,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitIdentity.js","sourceRoot":"","sources":["../../src/script/GitIdentity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GitIdentity.js","sourceRoot":"","sources":["../../src/script/GitIdentity.ts"],"names":[],"mappings":";;;;AAAA,2DAA8C;AAC9C,2EAAyF;AAqCzF;;;GAGG;AACI,MAAM,YAAY,GAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CACxD,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;IACtB,IAAA,6BAAQ,EAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3F,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACzC,OAAO,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AANQ,QAAA,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,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,IAAI,oCAAgB,CACxB,gHAAgH;QAC9G,iEAAiE,CACpE,CAAC;AACJ,CAAC"}
|
package/dist/script/GitSync.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScriptRepo, type GitIdentity } from "@bluestep-systems/b6p-core-bsjs-git";
|
|
1
|
+
import { ScriptRepo, type BuildFastForward, type DraftBuildRefusalReason, type DraftCompileOutcome, type GitIdentity } from "@bluestep-systems/b6p-core-bsjs-git";
|
|
2
2
|
import type { ScriptKey } from "../data/ScriptKey";
|
|
3
3
|
import type { ScriptContext } from "./ScriptContext";
|
|
4
4
|
/**
|
|
@@ -181,15 +181,18 @@ export interface DraftPushOptions {
|
|
|
181
181
|
*/
|
|
182
182
|
readonly adoptUnbound: boolean;
|
|
183
183
|
/**
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* `
|
|
184
|
+
* After the push, ask the platform to build the pushed draft ({@link ScriptRepo.compileDraft}) and fast-forward to
|
|
185
|
+
* the build commit it makes; a snapshot then publishes the build, unless the build failed or ended in a status that
|
|
186
|
+
* does not publish. Without it a snapshot publishes the pushed commit as it is (the platform's manifest check still
|
|
187
|
+
* applies); `executePush` never asks for that, it takes no snapshot on a server that does not build.
|
|
188
188
|
* @lastreviewed null
|
|
189
189
|
*/
|
|
190
|
-
readonly
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
readonly build?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Waits between the build's retries; tests pass a recorder.
|
|
193
|
+
* @lastreviewed null
|
|
194
|
+
*/
|
|
195
|
+
readonly sleep?: (ms: number) => Promise<void>;
|
|
193
196
|
/**
|
|
194
197
|
* The caller already confirmed switching a WebDAV script to git, so do not ask.
|
|
195
198
|
* @lastreviewed null
|
|
@@ -216,6 +219,61 @@ export interface PublishRefusal {
|
|
|
216
219
|
readonly reason: string;
|
|
217
220
|
readonly withheld: string[];
|
|
218
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* The build half of a {@link DraftPushOutcome}: what the platform's build of the pushed draft came to.
|
|
224
|
+
* @lastreviewed null
|
|
225
|
+
*/
|
|
226
|
+
export interface DraftBuildOutcome {
|
|
227
|
+
/**
|
|
228
|
+
* The platform's compile: status, counts and diagnostics. `null` when the build request failed (see `error`).
|
|
229
|
+
* @lastreviewed null
|
|
230
|
+
*/
|
|
231
|
+
readonly compile: DraftCompileOutcome | null;
|
|
232
|
+
/**
|
|
233
|
+
* The build commit the platform made, the platform draft's head. `null` when it made none (already built, nothing to
|
|
234
|
+
* build, the compile did not run) or the request failed. The local draft is there too unless `fastForward` says it
|
|
235
|
+
* is not.
|
|
236
|
+
* @lastreviewed null
|
|
237
|
+
*/
|
|
238
|
+
readonly buildCommitSha: string | null;
|
|
239
|
+
/**
|
|
240
|
+
* How the local draft folder was moved to `buildCommitSha`: `fast-forwarded`, `unchanged` (no build commit),
|
|
241
|
+
* `blocked` (local files in the way, listed; nothing changed here) or `failed`. `null` when no build answer came.
|
|
242
|
+
* @lastreviewed null
|
|
243
|
+
*/
|
|
244
|
+
readonly fastForward: BuildFastForward | null;
|
|
245
|
+
/**
|
|
246
|
+
* Set when the platform could not tell whether its build landed: `buildFound` says whether the draft, read back, was
|
|
247
|
+
* a build of the push (then taken in as `fastForward` says). Nothing is published after it. `null` otherwise.
|
|
248
|
+
* @lastreviewed null
|
|
249
|
+
*/
|
|
250
|
+
readonly outcomeUnknown: {
|
|
251
|
+
readonly buildFound: boolean;
|
|
252
|
+
} | null;
|
|
253
|
+
/**
|
|
254
|
+
* Whether the draft passes the platform's build check (a clean build with its manifest committed, or none needed).
|
|
255
|
+
* @lastreviewed null
|
|
256
|
+
*/
|
|
257
|
+
readonly vouched: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Why no build answer came, when none did; the push itself succeeded.
|
|
260
|
+
* @lastreviewed null
|
|
261
|
+
*/
|
|
262
|
+
readonly error: string | null;
|
|
263
|
+
/**
|
|
264
|
+
* What `error` is: `not-requested` (no build was asked for: the platform's draft was no longer the pushed commit),
|
|
265
|
+
* `refused` (the platform refused the build, `errorReason`; nothing was built), `request-failed` (any other failure;
|
|
266
|
+
* it may have run). `null` with no error.
|
|
267
|
+
* @lastreviewed null
|
|
268
|
+
*/
|
|
269
|
+
readonly errorKind: "not-requested" | "refused" | "request-failed" | null;
|
|
270
|
+
/**
|
|
271
|
+
* The platform's refusal reason when `errorKind` is `refused` (`DRAFT_MOVED`, `DRAFT_TOO_LARGE`, `REPO_MISSING`,
|
|
272
|
+
* `DRAFT_BRANCH_MISSING`); `null` otherwise.
|
|
273
|
+
* @lastreviewed null
|
|
274
|
+
*/
|
|
275
|
+
readonly errorReason: DraftBuildRefusalReason | null;
|
|
276
|
+
}
|
|
219
277
|
/**
|
|
220
278
|
* The publish half of a {@link DraftPushOutcome}.
|
|
221
279
|
* @lastreviewed null
|
|
@@ -265,7 +323,13 @@ export interface DraftPushOutcome {
|
|
|
265
323
|
*/
|
|
266
324
|
readonly keptPlatformOnly: string[];
|
|
267
325
|
/**
|
|
268
|
-
* Set when the push was asked to
|
|
326
|
+
* Set when the push was asked to build.
|
|
327
|
+
* @lastreviewed null
|
|
328
|
+
*/
|
|
329
|
+
readonly build?: DraftBuildOutcome;
|
|
330
|
+
/**
|
|
331
|
+
* Set when the push was asked to publish and, with `build`, the build let it: the build request did not fail and its
|
|
332
|
+
* status is one that publishes ({@link compileAllowsPublish}). Absent otherwise; `build` says why.
|
|
269
333
|
* @lastreviewed null
|
|
270
334
|
*/
|
|
271
335
|
readonly publish?: DraftPublishOutcome;
|
|
@@ -286,7 +350,9 @@ export declare function confirmOverwrittenFiles(opts: {
|
|
|
286
350
|
preConfirmed?: readonly string[];
|
|
287
351
|
}): Promise<void>;
|
|
288
352
|
/**
|
|
289
|
-
* Commits the draft folder's changes to the script's draft branch
|
|
353
|
+
* Commits the draft folder's changes to the script's draft branch and pushes it; with `build`, asks the platform to
|
|
354
|
+
* build the pushed commit and fast-forwards the folder to the build commit (the platform compiles; nothing compiles
|
|
355
|
+
* here); for a snapshot, then publishes the build commit.
|
|
290
356
|
*
|
|
291
357
|
* Where the repo lives depends on the folder, and the script's publish mode (read first, never assumed from a repo
|
|
292
358
|
* being there) decides whether a switch is needed:
|
|
@@ -305,7 +371,8 @@ export declare function confirmOverwrittenFiles(opts: {
|
|
|
305
371
|
* follow git's ignore rules, including the old script-root `.gitignore` rules ({@link legacyIgnoreRulesForDraft}).
|
|
306
372
|
* Nothing is read through a symbolic link.
|
|
307
373
|
*
|
|
308
|
-
* Once the push has succeeded, nothing that follows throws: a failed
|
|
374
|
+
* Once the push has succeeded, nothing that follows throws: a failed build comes back as `build.error` and a failed
|
|
375
|
+
* publish as `publish.error`.
|
|
309
376
|
*
|
|
310
377
|
* @throws an {@link Err.OverwriteDeclinedError} when an overwrite is not confirmed.
|
|
311
378
|
* @throws {GitSwitchDeclinedError} when the switch is needed and declined.
|