@segmentstream/ontology 0.170.1 → 0.171.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 +24 -0
- package/README.md +2 -3
- package/dist/errors.d.ts +0 -5
- package/dist/errors.js +0 -5
- package/dist/service/authentication.d.ts +1 -1
- package/dist/service/authentication.js +5 -4
- package/dist/service/config.d.ts +2 -0
- package/dist/service/config.js +10 -1
- package/dist/service/errors.js +1 -13
- package/dist/service/schemas.js +3 -1
- package/dist/service/service.js +2 -2
- package/dist/storage/authorization.js +4 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.171.0
|
|
4
|
+
|
|
5
|
+
A deployment that changes the ontology no longer refuses file operations or workflow actions
|
|
6
|
+
while it switches over. Before, once the deployment had migrated the catalog, the running version
|
|
7
|
+
answered every file download, upload and action that takes a file with the retryable 503
|
|
8
|
+
`ontology_updating` until the new version was promoted, about a minute and a half. Pipeline
|
|
9
|
+
worker actions were refused in that window too. A workflow run that the earlier deployment had
|
|
10
|
+
started was refused at every action, even after the promotion, and a workflow step fails on that
|
|
11
|
+
refusal, so those runs died at their next action. Now the running version serves files as it serves
|
|
12
|
+
every other request, waiting only while the migration's transaction holds the catalog. A run in
|
|
13
|
+
flight keeps acting with the code that started it against the new catalog, as the SDK's
|
|
14
|
+
deployment notes describe.
|
|
15
|
+
|
|
16
|
+
An upload stays tied to the version that started it: one started before the switch and saved
|
|
17
|
+
after it is refused, and the client starts it again.
|
|
18
|
+
|
|
19
|
+
The service no longer answers `ontology_updating`, and `PermissionDenied` no longer carries
|
|
20
|
+
`updating`. A workspace that retries `ontology_updating` itself can drop that retry after
|
|
21
|
+
upgrading.
|
|
22
|
+
|
|
23
|
+
## 0.170.2
|
|
24
|
+
|
|
25
|
+
Workspace apps and ontology services call the production API at segmentstream.com. Existing signed token issuers, OAuth registrations and custom API origins continue to work.
|
|
26
|
+
|
|
3
27
|
## 0.170.1
|
|
4
28
|
|
|
5
29
|
A connection call that names no `api` reaches the connection's `default_api` or, when the
|
package/README.md
CHANGED
|
@@ -1744,9 +1744,8 @@ action takes several uploads of the entity, `record_id` when it changes an exist
|
|
|
1744
1744
|
`transfer.headers`, calls `files_upload_complete` with `upload.id` for `upload.ticket`, then
|
|
1745
1745
|
calls the action tool with the ticket in its upload field and `_options` set to `options`. Both
|
|
1746
1746
|
tools run the REST upload sessions above, with the same checks, limits and permissions. A
|
|
1747
|
-
failure of the storage provider answers `storage_unavailable`,
|
|
1748
|
-
|
|
1749
|
-
`retryable: true`, so the client repeats the same call, ideally with its own `idempotency_key`.
|
|
1747
|
+
failure of the storage provider answers `storage_unavailable`, a 503 with `retryable: true`, so
|
|
1748
|
+
the client repeats the same call, ideally with its own `idempotency_key`.
|
|
1750
1749
|
While a failed attempt still holds an upload, a retry answers 409 `conflict` with
|
|
1751
1750
|
`retryable: true` and `retry_after` seconds; a conflict without `retryable` cannot resume.
|
|
1752
1751
|
|
package/dist/errors.d.ts
CHANGED
|
@@ -85,11 +85,6 @@ declare const PermissionDenied_base: Schema.Class<PermissionDenied, Schema.Tagge
|
|
|
85
85
|
readonly message: Schema.String;
|
|
86
86
|
/** The permission that is missing, for example `lead:changeStatus`. */
|
|
87
87
|
readonly permission: Schema.optionalKey<Schema.String>;
|
|
88
|
-
/**
|
|
89
|
-
* Refused only because the running ontology and the database catalog differ, as while a
|
|
90
|
-
* deployment migrates. The caller retries the same request.
|
|
91
|
-
*/
|
|
92
|
-
readonly updating: Schema.optionalKey<Schema.Literal<true>>;
|
|
93
88
|
}>, import("effect/Cause").YieldableError>;
|
|
94
89
|
/**
|
|
95
90
|
* The principal's roles do not grant a permission the request requires. The service answers 403
|
package/dist/errors.js
CHANGED
|
@@ -61,11 +61,6 @@ export class PermissionDenied extends Schema.TaggedError()("PermissionDenied", {
|
|
|
61
61
|
message: Schema.String,
|
|
62
62
|
/** The permission that is missing, for example `lead:changeStatus`. */
|
|
63
63
|
permission: Schema.optionalKey(Schema.String),
|
|
64
|
-
/**
|
|
65
|
-
* Refused only because the running ontology and the database catalog differ, as while a
|
|
66
|
-
* deployment migrates. The caller retries the same request.
|
|
67
|
-
*/
|
|
68
|
-
updating: Schema.optionalKey(Schema.Literal(true)),
|
|
69
64
|
}) {
|
|
70
65
|
}
|
|
71
66
|
// @legacy ontology.workflow-cutover-artifacts
|
|
@@ -6,7 +6,7 @@ import { type DeploymentObservation } from "../deployment.js";
|
|
|
6
6
|
import { type BrowserRevision } from "./federation-status.js";
|
|
7
7
|
import type { WorkloadExecution } from "../runtime/workload.js";
|
|
8
8
|
import type { ChatProvenance, Principal } from "../runtime.js";
|
|
9
|
-
import type
|
|
9
|
+
import { type NeonAuthEnvironment } from "./config.js";
|
|
10
10
|
import { RequestId } from "./errors.js";
|
|
11
11
|
import { CurrentCaller, type VerifiedCaller } from "./caller-context.js";
|
|
12
12
|
import { OntologyBackend, type SignInIdentity } from "./runtime-contract.js";
|
|
@@ -8,6 +8,7 @@ import { previewRunsAgent, requireDeploymentCapability, } from "../deployment.js
|
|
|
8
8
|
import { API_KEY_PREFIX } from "../runtime/principals.js";
|
|
9
9
|
import { FEDERATION_TOKEN_PREFIX, federationDigest } from "../runtime/federation.js";
|
|
10
10
|
import { browserRevisionAdmitted, browserRevisionObservation, browserSessionAdmission, federationStatus, } from "./federation-status.js";
|
|
11
|
+
import { platformTokenIssuer } from "./config.js";
|
|
11
12
|
import { RequestId, crossOriginSession, forbidden, internalError, notInvited, toServerResponse, unauthorized, unavailable, } from "./errors.js";
|
|
12
13
|
import { ACCESS_TOKEN_PREFIX, appSessionResource, publicOrigin, callerOfAccessToken, READ_SCOPE, rejectedAccessToken, scopedPrincipal, } from "./oauth/protocol.js";
|
|
13
14
|
import { CurrentCaller } from "./caller-context.js";
|
|
@@ -71,7 +72,7 @@ function identityFromClaims(config, payload) {
|
|
|
71
72
|
if (!mapping ||
|
|
72
73
|
typeof mapping !== "object" ||
|
|
73
74
|
mapping.issuer !==
|
|
74
|
-
(config.oidc?.issuer ?? `${
|
|
75
|
+
(config.oidc?.issuer ?? `${platformTokenIssuer(config.segmentstreamUrl)}/oidc`) ||
|
|
75
76
|
typeof mapping.subject !== "string" ||
|
|
76
77
|
!mapping.subject) {
|
|
77
78
|
return undefined;
|
|
@@ -91,7 +92,7 @@ function identityFromClaims(config, payload) {
|
|
|
91
92
|
* `SEGMENTSTREAM_URL` for this application (`aud: app:<application id>`), organization and workspace.
|
|
92
93
|
*/
|
|
93
94
|
export function makeTokenVerifier(config, keySet) {
|
|
94
|
-
const issuer =
|
|
95
|
+
const issuer = platformTokenIssuer(config.segmentstreamUrl);
|
|
95
96
|
const audience = `app:${config.applicationId}`;
|
|
96
97
|
return async function verifyToken(token) {
|
|
97
98
|
let payload;
|
|
@@ -151,7 +152,7 @@ export function makeWorkloadTokenVerifier(config, keySet) {
|
|
|
151
152
|
const verified = await jwtVerify(token, keySet, {
|
|
152
153
|
algorithms: ["ES256"],
|
|
153
154
|
typ: WORKLOAD_TOKEN_TYPE,
|
|
154
|
-
issuer:
|
|
155
|
+
issuer: platformTokenIssuer(config.segmentstreamUrl),
|
|
155
156
|
audience: `ontology:${config.applicationId}`,
|
|
156
157
|
clockTolerance: CLOCK_TOLERANCE_SECONDS,
|
|
157
158
|
requiredClaims: [
|
|
@@ -333,7 +334,7 @@ export function tokenVerifier(config) {
|
|
|
333
334
|
}
|
|
334
335
|
};
|
|
335
336
|
const verifiers = new Map([
|
|
336
|
-
[
|
|
337
|
+
[platformTokenIssuer(config.segmentstreamUrl), platform],
|
|
337
338
|
]);
|
|
338
339
|
if (config.neonAuth !== undefined &&
|
|
339
340
|
(!config.browserMethods || config.browserMethods.includes("email"))) {
|
package/dist/service/config.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import type { PageCatalogV1 } from "../navigation-catalog.js";
|
|
|
9
9
|
import { type ConnectionTransportFactory, type LocalConnectionContext } from "./connections.js";
|
|
10
10
|
import type { OntologyServiceRuntime } from "./runtime-contract.js";
|
|
11
11
|
import type { RuntimeIdentityConfig } from "./runtime-identity.js";
|
|
12
|
+
/** A signed issuer stays stable when the platform API moves. */
|
|
13
|
+
export declare function platformTokenIssuer(apiUrl: string): string;
|
|
12
14
|
/** The environment of the workspace deployment's ontology service. */
|
|
13
15
|
export declare const ENVIRONMENT_VARIABLES: {
|
|
14
16
|
readonly databaseUrl: "SEGMENTSTREAM_ONTOLOGY_DATABASE_URL";
|
package/dist/service/config.js
CHANGED
|
@@ -3,6 +3,14 @@ import { Redacted, Schema } from "effect";
|
|
|
3
3
|
import { BlobStorageBinding } from "../storage/provider.js";
|
|
4
4
|
import { deploymentFromEnv, previewRunsAgent } from "../deployment.js";
|
|
5
5
|
import { LocalConnectionContextError, readLocalConnectionContext, RUNTIME_CONTEXT_FD, } from "./connections.js";
|
|
6
|
+
// @legacy website.cloud-domain-serving
|
|
7
|
+
const productionIssuer = "https://cloud.segmentstream.com";
|
|
8
|
+
const productionApi = "https://segmentstream.com";
|
|
9
|
+
/** A signed issuer stays stable when the platform API moves. */
|
|
10
|
+
export function platformTokenIssuer(apiUrl) {
|
|
11
|
+
const origin = new URL(apiUrl).origin;
|
|
12
|
+
return origin === productionApi ? productionIssuer : origin;
|
|
13
|
+
}
|
|
6
14
|
/** The environment of the workspace deployment's ontology service. */
|
|
7
15
|
export const ENVIRONMENT_VARIABLES = {
|
|
8
16
|
databaseUrl: "SEGMENTSTREAM_ONTOLOGY_DATABASE_URL",
|
|
@@ -190,11 +198,12 @@ export function configFromEnv(environment = process.env) {
|
|
|
190
198
|
}
|
|
191
199
|
}
|
|
192
200
|
const previews = telegramPreviewEnvironment(environment);
|
|
201
|
+
const apiOrigin = normalizeUrl(ENVIRONMENT_VARIABLES.segmentstreamUrl, read(ENVIRONMENT_VARIABLES.segmentstreamUrl));
|
|
193
202
|
return {
|
|
194
203
|
...previews,
|
|
195
204
|
deployment,
|
|
196
205
|
databaseUrl: checkDatabaseUrl(ENVIRONMENT_VARIABLES.databaseUrl, read(ENVIRONMENT_VARIABLES.databaseUrl)),
|
|
197
|
-
segmentstreamUrl:
|
|
206
|
+
segmentstreamUrl: apiOrigin === productionIssuer ? productionApi : apiOrigin,
|
|
198
207
|
applicationId: read(ENVIRONMENT_VARIABLES.applicationId),
|
|
199
208
|
workspaceId: read(ENVIRONMENT_VARIABLES.workspaceId),
|
|
200
209
|
organizationId: read(ENVIRONMENT_VARIABLES.organizationId),
|
package/dist/service/errors.js
CHANGED
|
@@ -506,19 +506,7 @@ export function expectedFailure(error, requestId) {
|
|
|
506
506
|
};
|
|
507
507
|
}
|
|
508
508
|
if (Predicate.isTagged(error, "PermissionDenied")) {
|
|
509
|
-
const { permission
|
|
510
|
-
if (updating === true) {
|
|
511
|
-
return {
|
|
512
|
-
status: 503,
|
|
513
|
-
body: {
|
|
514
|
-
error: "ontology_updating",
|
|
515
|
-
detail: "The app is being updated. Retry the same request shortly.",
|
|
516
|
-
requestId,
|
|
517
|
-
retryable: true,
|
|
518
|
-
},
|
|
519
|
-
headers: { "retry-after": "5" },
|
|
520
|
-
};
|
|
521
|
-
}
|
|
509
|
+
const { permission } = error;
|
|
522
510
|
return {
|
|
523
511
|
status: 403,
|
|
524
512
|
body: {
|
package/dist/service/schemas.js
CHANGED
|
@@ -620,7 +620,9 @@ export const ErrorSchemas = {
|
|
|
620
620
|
rateLimited: errorBody("RateLimited", 429, ["rate_limited"]),
|
|
621
621
|
internal: errorBody("InternalError", 500, ["internal_error"]),
|
|
622
622
|
unavailable: errorBody("ServiceUnavailable", 503, ["service_unavailable"]),
|
|
623
|
-
storageUnavailable: errorBody("StorageUnavailable", 503, ["storage_unavailable"
|
|
623
|
+
storageUnavailable: errorBody("StorageUnavailable", 503, ["storage_unavailable"], {
|
|
624
|
+
retryable: Schema.Boolean,
|
|
625
|
+
}),
|
|
624
626
|
invalidMetricQuery: errorBody("InvalidMetricQuery", 400, ["invalid_aggregate_query"]),
|
|
625
627
|
readForbidden: errorBody("ReadForbidden", 403, ["forbidden", "scoped_aggregate_unavailable"], {
|
|
626
628
|
permissions: Schema.optionalKey(Schema.Array(Schema.String)),
|
package/dist/service/service.js
CHANGED
|
@@ -34,7 +34,7 @@ import { platformWarehouseQueries, WarehouseQueries } from "./warehouse-platform
|
|
|
34
34
|
import { BASE_PATH, ErrorResponsesLive, buildApi } from "./api.js";
|
|
35
35
|
import { CurrentPrincipal, authenticationLayer, neonAuthSessionExchange, tokenVerifier, withPrincipal, } from "./authentication.js";
|
|
36
36
|
import { currentCaller } from "./caller-context.js";
|
|
37
|
-
import { OntologyServiceConfigError, } from "./config.js";
|
|
37
|
+
import { platformTokenIssuer, OntologyServiceConfigError, } from "./config.js";
|
|
38
38
|
import { RequestId, failureResponse, internalError, errorBodyForWire, routeNotFound, toServerResponse, } from "./errors.js";
|
|
39
39
|
import { deployedConnections, localConnections } from "./connections.js";
|
|
40
40
|
import { DocsRoute } from "./docs.js";
|
|
@@ -321,7 +321,7 @@ export function createOntologyService(ontology, config) {
|
|
|
321
321
|
? {
|
|
322
322
|
issuer: config.browserRevisionIssuer ??
|
|
323
323
|
config.oidc?.issuer ??
|
|
324
|
-
`${
|
|
324
|
+
`${platformTokenIssuer(config.segmentstreamUrl)}/oidc`,
|
|
325
325
|
clientId: config.browserRevisionClientId,
|
|
326
326
|
manifestDigest: ontology.manifest.hash,
|
|
327
327
|
...(config.browserEnvironment !== "local" ? { deploymentId: deployment.deploymentId } : {}),
|
|
@@ -11,17 +11,10 @@ export function authorizeBlobOperation(ontology, sql, principalId, required, exe
|
|
|
11
11
|
/** The workflow a workflow user's principal acts for, with its subject in this workspace. */
|
|
12
12
|
workflowPrincipal) {
|
|
13
13
|
return Effect.gen(function* () {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
appliedHash: catalog?.hash ?? null,
|
|
19
|
-
});
|
|
20
|
-
return yield* new PermissionDenied({
|
|
21
|
-
message: "The deployed ontology no longer matches the database catalog.",
|
|
22
|
-
updating: true,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
14
|
+
// Lock the catalog first, in the order a migration takes it, so this operation waits for a
|
|
15
|
+
// migration in progress rather than deadlocking with it. A catalog that differs from the one
|
|
16
|
+
// this version serves is not refused: the version keeps serving until the next is promoted.
|
|
17
|
+
yield* sql.unsafe(`SELECT 1 FROM "_ontology" WHERE id = true FOR SHARE`, []);
|
|
25
18
|
const users = yield* sql.unsafe(`SELECT kind::text, active, identity_provider, identity_subject FROM "user" WHERE id = $1::uuid FOR SHARE`, [principalId]);
|
|
26
19
|
const user = users[0];
|
|
27
20
|
const roles = yield* sql.unsafe(`SELECT role FROM "_user_roles" WHERE user_id = $1::uuid FOR SHARE`, [principalId]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/ontology",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.171.0",
|
|
4
4
|
"description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|