@voyant-travel/apps 0.2.0 → 0.4.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.
Files changed (41) hide show
  1. package/dist/access-boundary.d.ts +29 -0
  2. package/dist/access-boundary.js +33 -0
  3. package/dist/api-runtime.d.ts +15 -0
  4. package/dist/api-runtime.js +15 -1
  5. package/dist/app-api-contracts.d.ts +51 -0
  6. package/dist/app-api-contracts.js +50 -0
  7. package/dist/app-api-routes.d.ts +28 -0
  8. package/dist/app-api-routes.js +141 -0
  9. package/dist/app-api-service.d.ts +1263 -0
  10. package/dist/app-api-service.js +244 -0
  11. package/dist/app-api-service.test.d.ts +1 -0
  12. package/dist/app-api-service.test.js +109 -0
  13. package/dist/consent.d.ts +15 -0
  14. package/dist/consent.js +65 -0
  15. package/dist/consent.test.d.ts +1 -0
  16. package/dist/consent.test.js +104 -0
  17. package/dist/contracts.d.ts +82 -3
  18. package/dist/contracts.js +50 -0
  19. package/dist/index.d.ts +8 -1
  20. package/dist/index.js +8 -1
  21. package/dist/installation-reconciliation.d.ts +1 -1
  22. package/dist/installation-reconciliation.js +5 -1
  23. package/dist/installation-service.d.ts +13 -2
  24. package/dist/installation-service.js +22 -7
  25. package/dist/oauth-crypto.d.ts +8 -0
  26. package/dist/oauth-crypto.js +23 -0
  27. package/dist/oauth-crypto.test.d.ts +1 -0
  28. package/dist/oauth-crypto.test.js +11 -0
  29. package/dist/oauth-service.d.ts +66 -0
  30. package/dist/oauth-service.js +398 -0
  31. package/dist/oauth-service.test.d.ts +1 -0
  32. package/dist/oauth-service.test.js +60 -0
  33. package/dist/routes.d.ts +8 -1
  34. package/dist/routes.js +70 -1
  35. package/dist/schema.d.ts +536 -4
  36. package/dist/schema.js +52 -1
  37. package/dist/service.d.ts +16 -16
  38. package/dist/voyant.js +87 -1
  39. package/migrations/20260717143000_app_oauth_authorization.sql +47 -0
  40. package/migrations/meta/_journal.json +7 -0
  41. package/package.json +40 -4
package/dist/service.d.ts CHANGED
@@ -8,14 +8,14 @@ export interface AppsServiceOptions extends CompileAppManifestOptions {
8
8
  }
9
9
  export declare function createAppsService(options?: AppsServiceOptions): {
10
10
  createCustomApp: (db: PostgresJsDatabase, input: CreateCustomAppRegistrationInput) => Promise<{
11
+ id: string;
12
+ platformNamespace: string;
13
+ distribution: "custom" | "marketplace";
11
14
  ownerId: string;
12
15
  displayName: string;
13
16
  slug: string;
14
- createdBy: string;
15
- distribution: "custom" | "marketplace";
16
- id: string;
17
- platformNamespace: string;
18
17
  lifecycleState: "active" | "suspended" | "deleted";
18
+ createdBy: string;
19
19
  createdAt: Date;
20
20
  updatedAt: Date;
21
21
  }>;
@@ -50,19 +50,19 @@ export declare function createAppsService(options?: AppsServiceOptions): {
50
50
  } | null>;
51
51
  releaseFromUpload: (db: PostgresJsDatabase, appId: string, input: ReleaseManifestUploadInput) => Promise<{
52
52
  release: {
53
- releaseVersion: string;
54
- apiCompatibility: {
55
- min: string;
56
- max: string;
57
- };
58
- createdBy: string;
59
53
  id: string;
54
+ createdBy: string;
60
55
  createdAt: Date;
61
56
  appId: string;
57
+ releaseVersion: string;
62
58
  manifestSchemaVersion: string;
63
59
  manifestDigest: string;
64
60
  manifestSnapshot: Record<string, unknown>;
65
61
  normalizedRecord: Record<string, unknown>;
62
+ apiCompatibility: {
63
+ min: string;
64
+ max: string;
65
+ };
66
66
  defaultLocale: string;
67
67
  supportedLocales: string[];
68
68
  state: "suspended" | "available" | "yanked";
@@ -72,19 +72,19 @@ export declare function createAppsService(options?: AppsServiceOptions): {
72
72
  }>;
73
73
  releaseFromFetch: (db: PostgresJsDatabase, appId: string, input: ReleaseManifestFetchInput) => Promise<{
74
74
  release: {
75
- releaseVersion: string;
76
- apiCompatibility: {
77
- min: string;
78
- max: string;
79
- };
80
- createdBy: string;
81
75
  id: string;
76
+ createdBy: string;
82
77
  createdAt: Date;
83
78
  appId: string;
79
+ releaseVersion: string;
84
80
  manifestSchemaVersion: string;
85
81
  manifestDigest: string;
86
82
  manifestSnapshot: Record<string, unknown>;
87
83
  normalizedRecord: Record<string, unknown>;
84
+ apiCompatibility: {
85
+ min: string;
86
+ max: string;
87
+ };
88
88
  defaultLocale: string;
89
89
  supportedLocales: string[];
90
90
  state: "suspended" | "available" | "yanked";
package/dist/voyant.js CHANGED
@@ -1,4 +1,5 @@
1
- import { defineModule } from "@voyant-travel/core/project";
1
+ import { defineModule, requirePort } from "@voyant-travel/core/project";
2
+ import { customFieldValueLifecycleRuntimePort, customFieldValueOperationsRuntimePort, } from "@voyant-travel/core/runtime-port";
2
3
  const appInstallationLifecyclePayloadSchema = {
3
4
  type: "object",
4
5
  additionalProperties: false,
@@ -13,6 +14,16 @@ export const appsVoyantModule = defineModule({
13
14
  id: "@voyant-travel/apps",
14
15
  packageName: "@voyant-travel/apps",
15
16
  localId: "apps",
17
+ runtimePorts: [
18
+ requirePort(customFieldValueLifecycleRuntimePort, {
19
+ optional: true,
20
+ cardinality: "many",
21
+ }),
22
+ requirePort(customFieldValueOperationsRuntimePort, {
23
+ optional: true,
24
+ cardinality: "many",
25
+ }),
26
+ ],
16
27
  api: [
17
28
  {
18
29
  id: "@voyant-travel/apps#api.admin",
@@ -82,6 +93,81 @@ export const appsVoyantModule = defineModule({
82
93
  ],
83
94
  access: {
84
95
  resources: [
96
+ {
97
+ id: "@voyant-travel/apps#access.app-installation",
98
+ resource: "app-installation",
99
+ label: "App installation",
100
+ description: "Read the calling app installation and grant state.",
101
+ remoteSafe: true,
102
+ actions: [{ action: "read", label: "Read installation", description: "Read self." }],
103
+ },
104
+ {
105
+ id: "@voyant-travel/apps#access.custom-field-definitions",
106
+ resource: "custom-field-definitions",
107
+ label: "Own custom-field definitions",
108
+ description: "Read and write custom-field definitions owned by the app.",
109
+ remoteSafe: true,
110
+ actions: ["read", "write"],
111
+ wildcard: "explicit-resource",
112
+ },
113
+ {
114
+ id: "@voyant-travel/apps#access.custom-field-values",
115
+ resource: "custom-field-values",
116
+ label: "Own custom-field values",
117
+ description: "Read and write app-owned custom-field values by target.",
118
+ remoteSafe: true,
119
+ actions: ["read", "write", "booking", "person", "organization", "invoice"],
120
+ wildcard: "explicit-resource",
121
+ },
122
+ {
123
+ id: "@voyant-travel/apps#access.webhooks",
124
+ resource: "webhooks",
125
+ label: "App webhooks",
126
+ description: "Read webhook health and request replay.",
127
+ remoteSafe: true,
128
+ actions: [
129
+ "read",
130
+ { action: "replay", label: "Replay webhooks", description: "Replay deliveries." },
131
+ ],
132
+ },
133
+ {
134
+ id: "@voyant-travel/apps#access.app-audit",
135
+ resource: "app-audit",
136
+ label: "App audit history",
137
+ description: "Read audit history owned by the app.",
138
+ remoteSafe: true,
139
+ actions: ["read"],
140
+ },
141
+ {
142
+ id: "@voyant-travel/apps#access.online-token",
143
+ resource: "online-token",
144
+ label: "Online token exchange",
145
+ description: "Exchange admin session context for online app access.",
146
+ remoteSafe: true,
147
+ actions: [{ action: "exchange", wildcard: "explicit" }],
148
+ },
149
+ {
150
+ id: "@voyant-travel/apps#access.finance-documents",
151
+ resource: "finance-documents",
152
+ label: "Finance documents",
153
+ description: "Read finance documents visible to remote accounting apps.",
154
+ remoteSafe: true,
155
+ actions: ["read"],
156
+ wildcard: "explicit-resource",
157
+ },
158
+ {
159
+ id: "@voyant-travel/apps#access.finance-actions",
160
+ resource: "finance-actions",
161
+ label: "Finance actions",
162
+ description: "Request approved finance document actions.",
163
+ remoteSafe: true,
164
+ actions: [
165
+ { action: "issue", sensitive: true, wildcard: "explicit" },
166
+ { action: "retry", sensitive: true, wildcard: "explicit" },
167
+ { action: "reconcile", sensitive: true, wildcard: "explicit" },
168
+ ],
169
+ wildcard: "explicit-resource",
170
+ },
85
171
  {
86
172
  id: "@voyant-travel/apps#access.apps",
87
173
  resource: "apps",
@@ -0,0 +1,47 @@
1
+ ALTER TYPE "public"."app_audit_event_kind" ADD VALUE IF NOT EXISTS 'consent';--> statement-breakpoint
2
+ ALTER TYPE "public"."app_audit_event_kind" ADD VALUE IF NOT EXISTS 'token';--> statement-breakpoint
3
+ CREATE TYPE "public"."app_access_token_mode" AS ENUM('offline', 'online');--> statement-breakpoint
4
+ ALTER TABLE "app_installations" ADD COLUMN "credential_generation" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
5
+ ALTER TABLE "app_access_credentials" ADD COLUMN "token_mode" "app_access_token_mode" DEFAULT 'offline' NOT NULL;--> statement-breakpoint
6
+ ALTER TABLE "app_access_credentials" ADD COLUMN "actor_id" text;--> statement-breakpoint
7
+ ALTER TABLE "app_access_credentials" ADD COLUMN "viewer_id" text;--> statement-breakpoint
8
+ DROP INDEX "public"."uidx_app_access_credentials_generation";--> statement-breakpoint
9
+ CREATE INDEX "idx_app_access_credentials_generation" ON "app_access_credentials" USING btree ("installation_id","token_mode","generation");--> statement-breakpoint
10
+ CREATE TABLE "app_oauth_authorization_codes" (
11
+ "id" text PRIMARY KEY NOT NULL,
12
+ "app_id" text NOT NULL,
13
+ "installation_id" text NOT NULL,
14
+ "release_id" text NOT NULL,
15
+ "deployment_id" text NOT NULL,
16
+ "code_hash" text NOT NULL,
17
+ "state_hash" text NOT NULL,
18
+ "redirect_uri" text NOT NULL,
19
+ "code_challenge" text NOT NULL,
20
+ "code_challenge_method" text NOT NULL,
21
+ "requested_scopes" jsonb NOT NULL,
22
+ "granted_scopes" jsonb NOT NULL,
23
+ "denied_optional_scopes" jsonb NOT NULL,
24
+ "actor_id" text NOT NULL,
25
+ "expires_at" timestamp with time zone NOT NULL,
26
+ "consumed_at" timestamp with time zone,
27
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
28
+ );--> statement-breakpoint
29
+ CREATE TABLE "app_oauth_refresh_tokens" (
30
+ "id" text PRIMARY KEY NOT NULL,
31
+ "installation_id" text NOT NULL,
32
+ "token_hash" text NOT NULL,
33
+ "generation" integer NOT NULL,
34
+ "status" "app_access_credential_status" DEFAULT 'active' NOT NULL,
35
+ "rotated_from_id" text,
36
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
37
+ "expires_at" timestamp with time zone,
38
+ "revoked_at" timestamp with time zone
39
+ );--> statement-breakpoint
40
+ ALTER TABLE "app_oauth_authorization_codes" ADD CONSTRAINT "app_oauth_authorization_codes_app_id_apps_id_fk" FOREIGN KEY ("app_id") REFERENCES "public"."apps"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
41
+ ALTER TABLE "app_oauth_authorization_codes" ADD CONSTRAINT "app_oauth_authorization_codes_installation_id_app_installations_id_fk" FOREIGN KEY ("installation_id") REFERENCES "public"."app_installations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
42
+ ALTER TABLE "app_oauth_authorization_codes" ADD CONSTRAINT "app_oauth_authorization_codes_release_id_app_releases_id_fk" FOREIGN KEY ("release_id") REFERENCES "public"."app_releases"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
43
+ ALTER TABLE "app_oauth_refresh_tokens" ADD CONSTRAINT "app_oauth_refresh_tokens_installation_id_app_installations_id_fk" FOREIGN KEY ("installation_id") REFERENCES "public"."app_installations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
44
+ CREATE UNIQUE INDEX "uidx_app_oauth_codes_hash" ON "app_oauth_authorization_codes" USING btree ("code_hash");--> statement-breakpoint
45
+ CREATE INDEX "idx_app_oauth_codes_installation" ON "app_oauth_authorization_codes" USING btree ("installation_id","expires_at");--> statement-breakpoint
46
+ CREATE UNIQUE INDEX "uidx_app_oauth_refresh_tokens_hash" ON "app_oauth_refresh_tokens" USING btree ("token_hash");--> statement-breakpoint
47
+ CREATE INDEX "idx_app_oauth_refresh_tokens_installation" ON "app_oauth_refresh_tokens" USING btree ("installation_id","status");
@@ -22,6 +22,13 @@
22
22
  "when": 1784291400000,
23
23
  "tag": "20260717123000_app_webhook_delivery_health",
24
24
  "breakpoints": true
25
+ },
26
+ {
27
+ "idx": 3,
28
+ "version": "7",
29
+ "when": 1784298600000,
30
+ "tag": "20260717143000_app_oauth_authorization",
31
+ "breakpoints": true
25
32
  }
26
33
  ]
27
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyant-travel/apps",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -9,6 +9,26 @@
9
9
  "import": "./dist/index.js",
10
10
  "default": "./dist/index.js"
11
11
  },
12
+ "./access-boundary": {
13
+ "types": "./dist/access-boundary.d.ts",
14
+ "import": "./dist/access-boundary.js",
15
+ "default": "./dist/access-boundary.js"
16
+ },
17
+ "./app-api-contracts": {
18
+ "types": "./dist/app-api-contracts.d.ts",
19
+ "import": "./dist/app-api-contracts.js",
20
+ "default": "./dist/app-api-contracts.js"
21
+ },
22
+ "./app-api-routes": {
23
+ "types": "./dist/app-api-routes.d.ts",
24
+ "import": "./dist/app-api-routes.js",
25
+ "default": "./dist/app-api-routes.js"
26
+ },
27
+ "./app-api-service": {
28
+ "types": "./dist/app-api-service.d.ts",
29
+ "import": "./dist/app-api-service.js",
30
+ "default": "./dist/app-api-service.js"
31
+ },
12
32
  "./api-runtime": {
13
33
  "types": "./dist/api-runtime.d.ts",
14
34
  "import": "./dist/api-runtime.js",
@@ -24,6 +44,11 @@
24
44
  "import": "./dist/contracts.js",
25
45
  "default": "./dist/contracts.js"
26
46
  },
47
+ "./consent": {
48
+ "types": "./dist/consent.d.ts",
49
+ "import": "./dist/consent.js",
50
+ "default": "./dist/consent.js"
51
+ },
27
52
  "./ingestion": {
28
53
  "types": "./dist/ingestion.d.ts",
29
54
  "import": "./dist/ingestion.js",
@@ -34,6 +59,16 @@
34
59
  "import": "./dist/installation-service.js",
35
60
  "default": "./dist/installation-service.js"
36
61
  },
62
+ "./oauth-crypto": {
63
+ "types": "./dist/oauth-crypto.d.ts",
64
+ "import": "./dist/oauth-crypto.js",
65
+ "default": "./dist/oauth-crypto.js"
66
+ },
67
+ "./oauth-service": {
68
+ "types": "./dist/oauth-service.d.ts",
69
+ "import": "./dist/oauth-service.js",
70
+ "default": "./dist/oauth-service.js"
71
+ },
37
72
  "./routes": {
38
73
  "types": "./dist/routes.d.ts",
39
74
  "import": "./dist/routes.js",
@@ -62,11 +97,12 @@
62
97
  "zod": "^4.4.3",
63
98
  "@voyant-travel/admin": "^0.126.2",
64
99
  "@voyant-travel/admin-extension-sdk": "^0.1.1",
65
- "@voyant-travel/core": "^0.125.0",
100
+ "@voyant-travel/core": "^0.125.2",
66
101
  "@voyant-travel/custom-fields": "^0.2.1",
67
102
  "@voyant-travel/db": "^0.114.10",
68
- "@voyant-travel/webhook-delivery": "^0.4.0",
69
- "@voyant-travel/hono": "^0.128.1"
103
+ "@voyant-travel/hono": "^0.128.3",
104
+ "@voyant-travel/types": "^0.109.4",
105
+ "@voyant-travel/webhook-delivery": "^0.4.0"
70
106
  },
71
107
  "devDependencies": {
72
108
  "@types/node": "^25.5.2",