@voyantjs/schema-kit 0.95.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.
@@ -0,0 +1,207 @@
1
+ import { typeIdSchema } from "./typeid-zod.js";
2
+ /**
3
+ * Pre-built Zod schemas for common entity types.
4
+ */
5
+ export const typeIdSchemas = {
6
+ userProfile: typeIdSchema("user_profiles"),
7
+ domain: typeIdSchema("domains"),
8
+ webhookSubscription: typeIdSchema("webhook_subscriptions"),
9
+ communicationLog: typeIdSchema("communication_log"),
10
+ notificationTemplate: typeIdSchema("notification_templates"),
11
+ notificationDelivery: typeIdSchema("notification_deliveries"),
12
+ personNote: typeIdSchema("person_notes"),
13
+ organizationNote: typeIdSchema("organization_notes"),
14
+ segment: typeIdSchema("segments"),
15
+ segmentMember: typeIdSchema("segment_members"),
16
+ supplier: typeIdSchema("suppliers"),
17
+ supplierService: typeIdSchema("supplier_services"),
18
+ supplierRate: typeIdSchema("supplier_rates"),
19
+ supplierNote: typeIdSchema("supplier_notes"),
20
+ supplierAvailability: typeIdSchema("supplier_availability"),
21
+ supplierContract: typeIdSchema("supplier_contracts"),
22
+ facility: typeIdSchema("facilities"),
23
+ facilityContact: typeIdSchema("facility_contacts"),
24
+ facilityFeature: typeIdSchema("facility_features"),
25
+ facilityOperationSchedule: typeIdSchema("facility_operation_schedules"),
26
+ property: typeIdSchema("properties"),
27
+ propertyGroup: typeIdSchema("property_groups"),
28
+ propertyGroupMember: typeIdSchema("property_group_members"),
29
+ market: typeIdSchema("markets"),
30
+ marketLocale: typeIdSchema("market_locales"),
31
+ marketCurrency: typeIdSchema("market_currencies"),
32
+ fxRateSet: typeIdSchema("fx_rate_sets"),
33
+ exchangeRate: typeIdSchema("exchange_rates"),
34
+ pricingCategory: typeIdSchema("pricing_categories"),
35
+ pricingCategoryDependency: typeIdSchema("pricing_category_dependencies"),
36
+ cancellationPolicy: typeIdSchema("cancellation_policies"),
37
+ cancellationPolicyRule: typeIdSchema("cancellation_policy_rules"),
38
+ priceCatalog: typeIdSchema("price_catalogs"),
39
+ priceSchedule: typeIdSchema("price_schedules"),
40
+ optionPriceRule: typeIdSchema("option_price_rules"),
41
+ optionUnitPriceRule: typeIdSchema("option_unit_price_rules"),
42
+ optionStartTimeRule: typeIdSchema("option_start_time_rules"),
43
+ optionUnitTier: typeIdSchema("option_unit_tiers"),
44
+ pickupPriceRule: typeIdSchema("pickup_price_rules"),
45
+ dropoffPriceRule: typeIdSchema("dropoff_price_rules"),
46
+ extraPriceRule: typeIdSchema("extra_price_rules"),
47
+ productExtra: typeIdSchema("product_extras"),
48
+ optionExtraConfig: typeIdSchema("option_extra_configs"),
49
+ bookingExtra: typeIdSchema("booking_extras"),
50
+ extraParticipantSelection: typeIdSchema("extra_participant_selections"),
51
+ productContactRequirement: typeIdSchema("product_contact_requirements"),
52
+ productBookingQuestion: typeIdSchema("product_booking_questions"),
53
+ optionBookingQuestion: typeIdSchema("option_booking_questions"),
54
+ bookingQuestionOption: typeIdSchema("booking_question_options"),
55
+ bookingQuestionUnitTrigger: typeIdSchema("booking_question_unit_triggers"),
56
+ bookingQuestionOptionTrigger: typeIdSchema("booking_question_option_triggers"),
57
+ bookingQuestionExtraTrigger: typeIdSchema("booking_question_extra_triggers"),
58
+ bookingAnswer: typeIdSchema("booking_answers"),
59
+ offer: typeIdSchema("offers"),
60
+ offerParticipant: typeIdSchema("offer_participants"),
61
+ offerItem: typeIdSchema("offer_items"),
62
+ offerItemParticipant: typeIdSchema("offer_item_participants"),
63
+ order: typeIdSchema("orders"),
64
+ orderParticipant: typeIdSchema("order_participants"),
65
+ orderItem: typeIdSchema("order_items"),
66
+ orderItemParticipant: typeIdSchema("order_item_participants"),
67
+ orderTerm: typeIdSchema("order_terms"),
68
+ marketPriceCatalog: typeIdSchema("market_price_catalogs"),
69
+ marketProductRule: typeIdSchema("market_product_rules"),
70
+ marketChannelRule: typeIdSchema("market_channel_rules"),
71
+ product: typeIdSchema("products"),
72
+ productOption: typeIdSchema("product_options"),
73
+ optionUnit: typeIdSchema("option_units"),
74
+ productActivationSetting: typeIdSchema("product_activation_settings"),
75
+ productTicketSetting: typeIdSchema("product_ticket_settings"),
76
+ productVisibilitySetting: typeIdSchema("product_visibility_settings"),
77
+ productCapability: typeIdSchema("product_capabilities"),
78
+ productDeliveryFormat: typeIdSchema("product_delivery_formats"),
79
+ productTranslation: typeIdSchema("product_translations"),
80
+ productOptionTranslation: typeIdSchema("product_option_translations"),
81
+ optionUnitTranslation: typeIdSchema("option_unit_translations"),
82
+ productDay: typeIdSchema("product_days"),
83
+ productDayService: typeIdSchema("product_day_services"),
84
+ productVersion: typeIdSchema("product_versions"),
85
+ productNote: typeIdSchema("product_notes"),
86
+ booking: typeIdSchema("bookings"),
87
+ bookingTraveler: typeIdSchema("booking_travelers"),
88
+ bookingParticipant: typeIdSchema("booking_travelers"),
89
+ bookingItem: typeIdSchema("booking_items"),
90
+ bookingItemTraveler: typeIdSchema("booking_item_travelers"),
91
+ bookingItemParticipant: typeIdSchema("booking_item_travelers"),
92
+ bookingPassenger: typeIdSchema("booking_travelers"),
93
+ bookingSupplierStatus: typeIdSchema("booking_supplier_statuses"),
94
+ bookingActivity: typeIdSchema("booking_activity_log"),
95
+ bookingNote: typeIdSchema("booking_notes"),
96
+ bookingDocument: typeIdSchema("booking_documents"),
97
+ availabilityRule: typeIdSchema("availability_rules"),
98
+ availabilityStartTime: typeIdSchema("availability_start_times"),
99
+ availabilitySlot: typeIdSchema("availability_slots"),
100
+ availabilityCloseout: typeIdSchema("availability_closeouts"),
101
+ availabilityPickupPoint: typeIdSchema("availability_pickup_points"),
102
+ availabilitySlotPickup: typeIdSchema("availability_slot_pickups"),
103
+ roomBlock: typeIdSchema("room_blocks"),
104
+ roomUnitStatusEvent: typeIdSchema("room_unit_status_events"),
105
+ maintenanceBlock: typeIdSchema("maintenance_blocks"),
106
+ housekeepingTask: typeIdSchema("housekeeping_tasks"),
107
+ stayOperation: typeIdSchema("stay_operations"),
108
+ stayCheckpoint: typeIdSchema("stay_checkpoints"),
109
+ stayServicePost: typeIdSchema("stay_service_posts"),
110
+ stayFolio: typeIdSchema("stay_folios"),
111
+ stayFolioLine: typeIdSchema("stay_folio_lines"),
112
+ roomTypeRate: typeIdSchema("room_type_rates"),
113
+ organization: typeIdSchema("organizations"),
114
+ person: typeIdSchema("people"),
115
+ pipeline: typeIdSchema("pipelines"),
116
+ stage: typeIdSchema("stages"),
117
+ opportunity: typeIdSchema("opportunities"),
118
+ opportunityParticipant: typeIdSchema("opportunity_participants"),
119
+ opportunityProduct: typeIdSchema("opportunity_products"),
120
+ quote: typeIdSchema("quotes"),
121
+ quoteLine: typeIdSchema("quote_lines"),
122
+ activity: typeIdSchema("activities"),
123
+ activityLink: typeIdSchema("activity_links"),
124
+ activityParticipant: typeIdSchema("activity_participants"),
125
+ customFieldDefinition: typeIdSchema("custom_field_definitions"),
126
+ customFieldValue: typeIdSchema("custom_field_values"),
127
+ invoice: typeIdSchema("invoices"),
128
+ paymentInstrument: typeIdSchema("payment_instruments"),
129
+ paymentSession: typeIdSchema("payment_sessions"),
130
+ paymentAuthorization: typeIdSchema("payment_authorizations"),
131
+ paymentCapture: typeIdSchema("payment_captures"),
132
+ bookingPaymentSchedule: typeIdSchema("booking_payment_schedules"),
133
+ bookingGuarantee: typeIdSchema("booking_guarantees"),
134
+ bookingItemTaxLine: typeIdSchema("booking_item_tax_lines"),
135
+ bookingItemCommission: typeIdSchema("booking_item_commissions"),
136
+ invoiceLineItem: typeIdSchema("invoice_line_items"),
137
+ payment: typeIdSchema("payments"),
138
+ creditNote: typeIdSchema("credit_notes"),
139
+ creditNoteLineItem: typeIdSchema("credit_note_line_items"),
140
+ supplierPayment: typeIdSchema("supplier_payments"),
141
+ financeNote: typeIdSchema("finance_notes"),
142
+ resource: typeIdSchema("resources"),
143
+ resourcePool: typeIdSchema("resource_pools"),
144
+ resourcePoolMember: typeIdSchema("resource_pool_members"),
145
+ resourceRequirement: typeIdSchema("resource_requirements"),
146
+ resourceAllocation: typeIdSchema("resource_requirements"),
147
+ resourceSlotAssignment: typeIdSchema("resource_slot_assignments"),
148
+ resourceCloseout: typeIdSchema("resource_closeouts"),
149
+ groundOperator: typeIdSchema("ground_operators"),
150
+ groundVehicle: typeIdSchema("ground_vehicles"),
151
+ groundDriver: typeIdSchema("ground_drivers"),
152
+ groundTransferPreference: typeIdSchema("ground_transfer_preferences"),
153
+ groundDispatch: typeIdSchema("ground_dispatches"),
154
+ groundExecutionEvent: typeIdSchema("ground_execution_events"),
155
+ groundDispatchAssignment: typeIdSchema("ground_dispatch_assignments"),
156
+ groundDispatchLeg: typeIdSchema("ground_dispatch_legs"),
157
+ groundDispatchPassenger: typeIdSchema("ground_dispatch_passengers"),
158
+ groundDriverShift: typeIdSchema("ground_driver_shifts"),
159
+ groundServiceIncident: typeIdSchema("ground_service_incidents"),
160
+ groundDispatchCheckpoint: typeIdSchema("ground_dispatch_checkpoints"),
161
+ channel: typeIdSchema("channels"),
162
+ channelContract: typeIdSchema("channel_contracts"),
163
+ channelCommissionRule: typeIdSchema("channel_commission_rules"),
164
+ channelProductMapping: typeIdSchema("channel_product_mappings"),
165
+ channelBookingLink: typeIdSchema("channel_booking_links"),
166
+ channelWebhookEvent: typeIdSchema("channel_webhook_events"),
167
+ channelSettlementRun: typeIdSchema("channel_settlement_runs"),
168
+ channelSettlementItem: typeIdSchema("channel_settlement_items"),
169
+ channelReconciliationRun: typeIdSchema("channel_reconciliation_runs"),
170
+ channelReconciliationItem: typeIdSchema("channel_reconciliation_items"),
171
+ channelInventoryReleaseExecution: typeIdSchema("channel_inventory_release_executions"),
172
+ channelSettlementPolicy: typeIdSchema("channel_settlement_policies"),
173
+ channelReconciliationPolicy: typeIdSchema("channel_reconciliation_policies"),
174
+ channelReleaseSchedule: typeIdSchema("channel_release_schedules"),
175
+ channelRemittanceException: typeIdSchema("channel_remittance_exceptions"),
176
+ channelSettlementApproval: typeIdSchema("channel_settlement_approvals"),
177
+ sellabilitySnapshot: typeIdSchema("sellability_snapshots"),
178
+ sellabilitySnapshotItem: typeIdSchema("sellability_snapshot_items"),
179
+ sellabilityPolicy: typeIdSchema("sellability_policies"),
180
+ sellabilityPolicyResult: typeIdSchema("sellability_policy_results"),
181
+ offerRefreshRun: typeIdSchema("offer_refresh_runs"),
182
+ offerExpirationEvent: typeIdSchema("offer_expiration_events"),
183
+ sellabilityExplanation: typeIdSchema("sellability_explanations"),
184
+ productMedia: typeIdSchema("product_media"),
185
+ productFeature: typeIdSchema("product_features"),
186
+ productFaq: typeIdSchema("product_faqs"),
187
+ productLocation: typeIdSchema("product_locations"),
188
+ productType: typeIdSchema("product_types"),
189
+ productCategory: typeIdSchema("product_categories"),
190
+ productTag: typeIdSchema("product_tags"),
191
+ contract: typeIdSchema("contracts"),
192
+ contractTemplate: typeIdSchema("contract_templates"),
193
+ contractTemplateVersion: typeIdSchema("contract_template_versions"),
194
+ contractSignature: typeIdSchema("contract_signatures"),
195
+ contractNumberSeries: typeIdSchema("contract_number_series"),
196
+ contractAttachment: typeIdSchema("contract_attachments"),
197
+ policy: typeIdSchema("policies"),
198
+ policyVersion: typeIdSchema("policy_versions"),
199
+ policyRule: typeIdSchema("policy_rules"),
200
+ policyAssignment: typeIdSchema("policy_assignments"),
201
+ policyAcceptance: typeIdSchema("policy_acceptances"),
202
+ invoiceNumberSeries: typeIdSchema("invoice_number_series"),
203
+ invoiceTemplate: typeIdSchema("invoice_templates"),
204
+ invoiceRendition: typeIdSchema("invoice_renditions"),
205
+ taxRegime: typeIdSchema("tax_regimes"),
206
+ invoiceExternalRef: typeIdSchema("invoice_external_refs"),
207
+ };
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ import { type PrefixKey, type PrefixValue } from "./typeid-prefixes.js";
3
+ export declare const TYPEID_SUFFIX_PATTERN = "[0-9a-hjkmnp-tv-z]{26}";
4
+ /**
5
+ * Creates a Zod schema for validating TypeIDs with a specific prefix.
6
+ */
7
+ export declare function typeIdSchema(prefix: PrefixKey | PrefixValue): z.ZodString;
8
+ /**
9
+ * Creates a Zod schema for validating any TypeID.
10
+ */
11
+ export declare function anyTypeIdSchema(): z.ZodString;
12
+ /**
13
+ * Creates a Zod schema that accepts either a TypeID or null/undefined.
14
+ */
15
+ export declare function typeIdSchemaOptional(prefix: PrefixKey | PrefixValue): z.ZodOptional<z.ZodNullable<z.ZodString>>;
16
+ //# sourceMappingURL=typeid-zod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeid-zod.d.ts","sourceRoot":"","sources":["../../src/typeid/typeid-zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEjF,eAAO,MAAM,qBAAqB,2BAA2B,CAAA;AAE7D;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,eAO3D;AAED;;GAEG;AACH,wBAAgB,eAAe,gBAM9B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,6CAEnE"}
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ import { PREFIXES } from "./typeid-prefixes.js";
3
+ export const TYPEID_SUFFIX_PATTERN = "[0-9a-hjkmnp-tv-z]{26}";
4
+ /**
5
+ * Creates a Zod schema for validating TypeIDs with a specific prefix.
6
+ */
7
+ export function typeIdSchema(prefix) {
8
+ const prefixValue = prefix in PREFIXES ? PREFIXES[prefix] : prefix;
9
+ const pattern = new RegExp(`^${prefixValue}_${TYPEID_SUFFIX_PATTERN}$`);
10
+ return z.string().regex(pattern, {
11
+ message: `Invalid TypeID: expected prefix "${prefixValue}_"`,
12
+ });
13
+ }
14
+ /**
15
+ * Creates a Zod schema for validating any TypeID.
16
+ */
17
+ export function anyTypeIdSchema() {
18
+ const pattern = new RegExp(`^[a-z][a-z0-9]{0,62}_${TYPEID_SUFFIX_PATTERN}$`);
19
+ return z.string().regex(pattern, {
20
+ message: "Invalid TypeID format",
21
+ });
22
+ }
23
+ /**
24
+ * Creates a Zod schema that accepts either a TypeID or null/undefined.
25
+ */
26
+ export function typeIdSchemaOptional(prefix) {
27
+ return typeIdSchema(prefix).nullable().optional();
28
+ }
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@voyantjs/schema-kit",
3
+ "version": "0.95.0",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./src/index.ts",
8
+ "./typeid": "./src/typeid/index.ts",
9
+ "./query-params": "./src/query-params.ts",
10
+ "./kms": "./src/kms.ts"
11
+ },
12
+ "scripts": {
13
+ "typecheck": "tsc --noEmit",
14
+ "lint": "biome check src/",
15
+ "test": "vitest run --passWithNoTests",
16
+ "build": "tsc -p tsconfig.json",
17
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
18
+ "prepack": "pnpm run build"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js",
29
+ "default": "./dist/index.js"
30
+ },
31
+ "./typeid": {
32
+ "types": "./dist/typeid/index.d.ts",
33
+ "import": "./dist/typeid/index.js",
34
+ "default": "./dist/typeid/index.js"
35
+ },
36
+ "./query-params": {
37
+ "types": "./dist/query-params.d.ts",
38
+ "import": "./dist/query-params.js",
39
+ "default": "./dist/query-params.js"
40
+ },
41
+ "./kms": {
42
+ "types": "./dist/kms.d.ts",
43
+ "import": "./dist/kms.js",
44
+ "default": "./dist/kms.js"
45
+ }
46
+ },
47
+ "main": "./dist/index.js",
48
+ "types": "./dist/index.d.ts"
49
+ },
50
+ "dependencies": {
51
+ "typeid-js": "^1.2.0",
52
+ "zod": "^4.3.6"
53
+ },
54
+ "devDependencies": {
55
+ "@voyantjs/voyant-typescript-config": "workspace:*",
56
+ "typescript": "^6.0.2",
57
+ "vitest": "^4.1.2"
58
+ },
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "https://github.com/voyantjs/voyant.git",
62
+ "directory": "packages/schema-kit"
63
+ }
64
+ }