@voyant-travel/catalog-authoring 0.106.18
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/LICENSE +201 -0
- package/dist/builder.d.ts +2 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +1 -0
- package/dist/clone-content.d.ts +38 -0
- package/dist/clone-content.d.ts.map +1 -0
- package/dist/clone-content.js +367 -0
- package/dist/clone-pricing.d.ts +9 -0
- package/dist/clone-pricing.d.ts.map +1 -0
- package/dist/clone-pricing.js +242 -0
- package/dist/clone.d.ts +2 -0
- package/dist/clone.d.ts.map +1 -0
- package/dist/clone.js +1 -0
- package/dist/errors.d.ts +2 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +1 -0
- package/dist/extension.d.ts +2 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/extension.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/schema.d.ts +2 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +1 -0
- package/dist/service.d.ts +2 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +1 -0
- package/dist/spec.d.ts +2 -0
- package/dist/spec.d.ts.map +1 -0
- package/dist/spec.js +1 -0
- package/dist/validate.d.ts +2 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +1 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may accept and charge a
|
|
167
|
+
fee for, the acceptance of support, warranty, indemnity, or
|
|
168
|
+
other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 PixelMakers Studio SRL
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,iBAAiB,GAClB,MAAM,oCAAoC,CAAA"}
|
package/dist/builder.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { buildProductGraph, } from "@voyant-travel/inventory/authoring";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
/** Shared, mutable state threaded across the clone copy phases (id remaps). */
|
|
3
|
+
export interface CloneContext {
|
|
4
|
+
tx: PostgresJsDatabase;
|
|
5
|
+
sourceId: string;
|
|
6
|
+
targetId: string;
|
|
7
|
+
copyDepartures: boolean;
|
|
8
|
+
optionIdMap: Map<string, string>;
|
|
9
|
+
unitIdMap: Map<string, string>;
|
|
10
|
+
unitsByNewOption: Map<string, {
|
|
11
|
+
id: string;
|
|
12
|
+
}[]>;
|
|
13
|
+
itineraryIdMap: Map<string, string>;
|
|
14
|
+
dayIdMap: Map<string, string>;
|
|
15
|
+
startTimeIdMap: Map<string, string>;
|
|
16
|
+
ruleIdMap: Map<string, string>;
|
|
17
|
+
slotIdMap: Map<string, string>;
|
|
18
|
+
optionPriceRuleIdMap: Map<string, string>;
|
|
19
|
+
optionUnitPriceRuleIdMap: Map<string, string>;
|
|
20
|
+
pricingCategoryIdMap: Map<string, string>;
|
|
21
|
+
productExtraIdMap: Map<string, string>;
|
|
22
|
+
optionExtraConfigIdMap: Map<string, string>;
|
|
23
|
+
}
|
|
24
|
+
type SystemColumns = {
|
|
25
|
+
id?: unknown;
|
|
26
|
+
createdAt?: unknown;
|
|
27
|
+
updatedAt?: unknown;
|
|
28
|
+
};
|
|
29
|
+
export declare function withoutSystemColumns<T extends SystemColumns>(row: T): Omit<T, "id" | "createdAt" | "updatedAt">;
|
|
30
|
+
/**
|
|
31
|
+
* Copies the product's content graph: per-product settings, options + units
|
|
32
|
+
* (with translations + resource templates), pricing categories (+ dependencies,
|
|
33
|
+
* remapped), itineraries/days/services, media, and extras. Populates the id
|
|
34
|
+
* remaps in {@link CloneContext} for the pricing/availability phase.
|
|
35
|
+
*/
|
|
36
|
+
export declare function copyProductContent(ctx: CloneContext): Promise<void>;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=clone-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone-content.d.ts","sourceRoot":"","sources":["../src/clone-content.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,kBAAkB,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,OAAO,CAAA;IACvB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,CAAA;IAC/C,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACnC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACnC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7C,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,sBAAsB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC5C;AAED,KAAK,aAAa,GAAG;IACnB,EAAE,CAAC,EAAE,OAAO,CAAA;IACZ,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,aAAa,EAAE,GAAG,EAAE,CAAC,6CAGnE;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA6HzE"}
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { productOptionResourceTemplates } from "@voyantjs/availability";
|
|
2
|
+
import { optionExtraConfigs, productExtras } from "@voyantjs/extras";
|
|
3
|
+
import { pricingCategories, pricingCategoryDependencies } from "@voyantjs/pricing/schema";
|
|
4
|
+
import { optionUnits, optionUnitTranslations, productActivationSettings, productCapabilities, productCategoryProducts, productDayServices, productDays, productDayTranslations, productDeliveryFormats, productDestinations, productFaqs, productFeatures, productItineraries, productLocations, productMedia, productOptions, productOptionTranslations, productTagProducts, productTicketSettings, productTranslations, productVisibilitySettings, } from "@voyantjs/products/schema";
|
|
5
|
+
import { eq, inArray } from "drizzle-orm";
|
|
6
|
+
export function withoutSystemColumns(row) {
|
|
7
|
+
const { id: _id, createdAt: _createdAt, updatedAt: _updatedAt, ...values } = row;
|
|
8
|
+
return values;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Copies the product's content graph: per-product settings, options + units
|
|
12
|
+
* (with translations + resource templates), pricing categories (+ dependencies,
|
|
13
|
+
* remapped), itineraries/days/services, media, and extras. Populates the id
|
|
14
|
+
* remaps in {@link CloneContext} for the pricing/availability phase.
|
|
15
|
+
*/
|
|
16
|
+
export async function copyProductContent(ctx) {
|
|
17
|
+
const { tx, sourceId, targetId } = ctx;
|
|
18
|
+
const activationRows = await tx
|
|
19
|
+
.select()
|
|
20
|
+
.from(productActivationSettings)
|
|
21
|
+
.where(eq(productActivationSettings.productId, sourceId));
|
|
22
|
+
for (const row of activationRows) {
|
|
23
|
+
await tx.insert(productActivationSettings).values({
|
|
24
|
+
...withoutSystemColumns(row),
|
|
25
|
+
productId: targetId,
|
|
26
|
+
activationMode: "manual",
|
|
27
|
+
activateAt: null,
|
|
28
|
+
deactivateAt: null,
|
|
29
|
+
sellAt: null,
|
|
30
|
+
stopSellAt: null,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const ticketRows = await tx
|
|
34
|
+
.select()
|
|
35
|
+
.from(productTicketSettings)
|
|
36
|
+
.where(eq(productTicketSettings.productId, sourceId));
|
|
37
|
+
for (const row of ticketRows) {
|
|
38
|
+
await tx
|
|
39
|
+
.insert(productTicketSettings)
|
|
40
|
+
.values({ ...withoutSystemColumns(row), productId: targetId });
|
|
41
|
+
}
|
|
42
|
+
const visibilityRows = await tx
|
|
43
|
+
.select()
|
|
44
|
+
.from(productVisibilitySettings)
|
|
45
|
+
.where(eq(productVisibilitySettings.productId, sourceId));
|
|
46
|
+
for (const row of visibilityRows) {
|
|
47
|
+
await tx
|
|
48
|
+
.insert(productVisibilitySettings)
|
|
49
|
+
.values({ ...withoutSystemColumns(row), productId: targetId });
|
|
50
|
+
}
|
|
51
|
+
const capabilityRows = await tx
|
|
52
|
+
.select()
|
|
53
|
+
.from(productCapabilities)
|
|
54
|
+
.where(eq(productCapabilities.productId, sourceId));
|
|
55
|
+
for (const row of capabilityRows) {
|
|
56
|
+
await tx
|
|
57
|
+
.insert(productCapabilities)
|
|
58
|
+
.values({ ...withoutSystemColumns(row), productId: targetId });
|
|
59
|
+
}
|
|
60
|
+
const deliveryFormatRows = await tx
|
|
61
|
+
.select()
|
|
62
|
+
.from(productDeliveryFormats)
|
|
63
|
+
.where(eq(productDeliveryFormats.productId, sourceId));
|
|
64
|
+
for (const row of deliveryFormatRows) {
|
|
65
|
+
await tx
|
|
66
|
+
.insert(productDeliveryFormats)
|
|
67
|
+
.values({ ...withoutSystemColumns(row), productId: targetId });
|
|
68
|
+
}
|
|
69
|
+
const featureRows = await tx
|
|
70
|
+
.select()
|
|
71
|
+
.from(productFeatures)
|
|
72
|
+
.where(eq(productFeatures.productId, sourceId));
|
|
73
|
+
for (const row of featureRows) {
|
|
74
|
+
await tx.insert(productFeatures).values({ ...withoutSystemColumns(row), productId: targetId });
|
|
75
|
+
}
|
|
76
|
+
const faqRows = await tx.select().from(productFaqs).where(eq(productFaqs.productId, sourceId));
|
|
77
|
+
for (const row of faqRows) {
|
|
78
|
+
await tx.insert(productFaqs).values({ ...withoutSystemColumns(row), productId: targetId });
|
|
79
|
+
}
|
|
80
|
+
const locationRows = await tx
|
|
81
|
+
.select()
|
|
82
|
+
.from(productLocations)
|
|
83
|
+
.where(eq(productLocations.productId, sourceId));
|
|
84
|
+
for (const row of locationRows) {
|
|
85
|
+
await tx.insert(productLocations).values({ ...withoutSystemColumns(row), productId: targetId });
|
|
86
|
+
}
|
|
87
|
+
const translationRows = await tx
|
|
88
|
+
.select()
|
|
89
|
+
.from(productTranslations)
|
|
90
|
+
.where(eq(productTranslations.productId, sourceId));
|
|
91
|
+
for (const row of translationRows) {
|
|
92
|
+
await tx
|
|
93
|
+
.insert(productTranslations)
|
|
94
|
+
.values({ ...withoutSystemColumns(row), productId: targetId });
|
|
95
|
+
}
|
|
96
|
+
const categoryRows = await tx
|
|
97
|
+
.select()
|
|
98
|
+
.from(productCategoryProducts)
|
|
99
|
+
.where(eq(productCategoryProducts.productId, sourceId));
|
|
100
|
+
for (const row of categoryRows) {
|
|
101
|
+
await tx
|
|
102
|
+
.insert(productCategoryProducts)
|
|
103
|
+
.values({ ...withoutSystemColumns(row), productId: targetId });
|
|
104
|
+
}
|
|
105
|
+
const tagRows = await tx
|
|
106
|
+
.select()
|
|
107
|
+
.from(productTagProducts)
|
|
108
|
+
.where(eq(productTagProducts.productId, sourceId));
|
|
109
|
+
for (const row of tagRows) {
|
|
110
|
+
await tx
|
|
111
|
+
.insert(productTagProducts)
|
|
112
|
+
.values({ ...withoutSystemColumns(row), productId: targetId });
|
|
113
|
+
}
|
|
114
|
+
const destinationRows = await tx
|
|
115
|
+
.select()
|
|
116
|
+
.from(productDestinations)
|
|
117
|
+
.where(eq(productDestinations.productId, sourceId));
|
|
118
|
+
for (const row of destinationRows) {
|
|
119
|
+
await tx
|
|
120
|
+
.insert(productDestinations)
|
|
121
|
+
.values({ ...withoutSystemColumns(row), productId: targetId });
|
|
122
|
+
}
|
|
123
|
+
await copyOptionsAndUnits(ctx);
|
|
124
|
+
await copyPricingCategories(ctx);
|
|
125
|
+
await copyItinerary(ctx);
|
|
126
|
+
await copyMedia(ctx);
|
|
127
|
+
await copyExtras(ctx);
|
|
128
|
+
}
|
|
129
|
+
async function copyOptionsAndUnits(ctx) {
|
|
130
|
+
const { tx, sourceId, targetId, optionIdMap, unitIdMap, unitsByNewOption } = ctx;
|
|
131
|
+
const sourceOptions = await tx
|
|
132
|
+
.select()
|
|
133
|
+
.from(productOptions)
|
|
134
|
+
.where(eq(productOptions.productId, sourceId));
|
|
135
|
+
for (const row of sourceOptions) {
|
|
136
|
+
const [copy] = await tx
|
|
137
|
+
.insert(productOptions)
|
|
138
|
+
.values({ ...withoutSystemColumns(row), productId: targetId })
|
|
139
|
+
.returning();
|
|
140
|
+
if (copy) {
|
|
141
|
+
optionIdMap.set(row.id, copy.id);
|
|
142
|
+
unitsByNewOption.set(copy.id, []);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const sourceOptionIds = sourceOptions.map((row) => row.id);
|
|
146
|
+
if (sourceOptionIds.length === 0)
|
|
147
|
+
return;
|
|
148
|
+
const optionTranslationRows = await tx
|
|
149
|
+
.select()
|
|
150
|
+
.from(productOptionTranslations)
|
|
151
|
+
.where(inArray(productOptionTranslations.optionId, sourceOptionIds));
|
|
152
|
+
for (const row of optionTranslationRows) {
|
|
153
|
+
const targetOptionId = optionIdMap.get(row.optionId);
|
|
154
|
+
if (!targetOptionId)
|
|
155
|
+
continue;
|
|
156
|
+
await tx
|
|
157
|
+
.insert(productOptionTranslations)
|
|
158
|
+
.values({ ...withoutSystemColumns(row), optionId: targetOptionId });
|
|
159
|
+
}
|
|
160
|
+
const sourceUnits = await tx
|
|
161
|
+
.select()
|
|
162
|
+
.from(optionUnits)
|
|
163
|
+
.where(inArray(optionUnits.optionId, sourceOptionIds));
|
|
164
|
+
for (const row of sourceUnits) {
|
|
165
|
+
const targetOptionId = optionIdMap.get(row.optionId);
|
|
166
|
+
if (!targetOptionId)
|
|
167
|
+
continue;
|
|
168
|
+
const [copy] = await tx
|
|
169
|
+
.insert(optionUnits)
|
|
170
|
+
.values({ ...withoutSystemColumns(row), optionId: targetOptionId })
|
|
171
|
+
.returning();
|
|
172
|
+
if (copy) {
|
|
173
|
+
unitIdMap.set(row.id, copy.id);
|
|
174
|
+
unitsByNewOption.get(targetOptionId)?.push({ id: copy.id });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const sourceUnitIds = sourceUnits.map((row) => row.id);
|
|
178
|
+
if (sourceUnitIds.length > 0) {
|
|
179
|
+
const unitTranslationRows = await tx
|
|
180
|
+
.select()
|
|
181
|
+
.from(optionUnitTranslations)
|
|
182
|
+
.where(inArray(optionUnitTranslations.unitId, sourceUnitIds));
|
|
183
|
+
for (const row of unitTranslationRows) {
|
|
184
|
+
const targetUnitId = unitIdMap.get(row.unitId);
|
|
185
|
+
if (!targetUnitId)
|
|
186
|
+
continue;
|
|
187
|
+
await tx
|
|
188
|
+
.insert(optionUnitTranslations)
|
|
189
|
+
.values({ ...withoutSystemColumns(row), unitId: targetUnitId });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const resourceTemplateRows = await tx
|
|
193
|
+
.select()
|
|
194
|
+
.from(productOptionResourceTemplates)
|
|
195
|
+
.where(inArray(productOptionResourceTemplates.productOptionId, sourceOptionIds));
|
|
196
|
+
for (const row of resourceTemplateRows) {
|
|
197
|
+
const targetOptionId = optionIdMap.get(row.productOptionId);
|
|
198
|
+
if (!targetOptionId)
|
|
199
|
+
continue;
|
|
200
|
+
await tx
|
|
201
|
+
.insert(productOptionResourceTemplates)
|
|
202
|
+
.values({ ...withoutSystemColumns(row), productOptionId: targetOptionId });
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async function copyPricingCategories(ctx) {
|
|
206
|
+
const { tx, sourceId, targetId, optionIdMap, unitIdMap, pricingCategoryIdMap } = ctx;
|
|
207
|
+
const pricingCategoryRows = await tx
|
|
208
|
+
.select()
|
|
209
|
+
.from(pricingCategories)
|
|
210
|
+
.where(eq(pricingCategories.productId, sourceId));
|
|
211
|
+
for (const row of pricingCategoryRows) {
|
|
212
|
+
const targetOptionId = row.optionId ? (optionIdMap.get(row.optionId) ?? null) : null;
|
|
213
|
+
const targetUnitId = row.unitId ? (unitIdMap.get(row.unitId) ?? null) : null;
|
|
214
|
+
if (row.optionId && !targetOptionId)
|
|
215
|
+
continue;
|
|
216
|
+
if (row.unitId && !targetUnitId)
|
|
217
|
+
continue;
|
|
218
|
+
const [copy] = await tx
|
|
219
|
+
.insert(pricingCategories)
|
|
220
|
+
.values({
|
|
221
|
+
...withoutSystemColumns(row),
|
|
222
|
+
productId: targetId,
|
|
223
|
+
optionId: targetOptionId,
|
|
224
|
+
unitId: targetUnitId,
|
|
225
|
+
})
|
|
226
|
+
.returning();
|
|
227
|
+
if (copy)
|
|
228
|
+
pricingCategoryIdMap.set(row.id, copy.id);
|
|
229
|
+
}
|
|
230
|
+
const sourcePricingCategoryIds = pricingCategoryRows.map((row) => row.id);
|
|
231
|
+
if (sourcePricingCategoryIds.length === 0)
|
|
232
|
+
return;
|
|
233
|
+
const dependencyRows = await tx
|
|
234
|
+
.select()
|
|
235
|
+
.from(pricingCategoryDependencies)
|
|
236
|
+
.where(inArray(pricingCategoryDependencies.pricingCategoryId, sourcePricingCategoryIds));
|
|
237
|
+
for (const row of dependencyRows) {
|
|
238
|
+
const targetPricingCategoryId = pricingCategoryIdMap.get(row.pricingCategoryId);
|
|
239
|
+
const targetMasterPricingCategoryId = pricingCategoryIdMap.get(row.masterPricingCategoryId);
|
|
240
|
+
if (!targetPricingCategoryId || !targetMasterPricingCategoryId)
|
|
241
|
+
continue;
|
|
242
|
+
await tx.insert(pricingCategoryDependencies).values({
|
|
243
|
+
...withoutSystemColumns(row),
|
|
244
|
+
pricingCategoryId: targetPricingCategoryId,
|
|
245
|
+
masterPricingCategoryId: targetMasterPricingCategoryId,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
async function copyItinerary(ctx) {
|
|
250
|
+
const { tx, sourceId, targetId, itineraryIdMap, dayIdMap } = ctx;
|
|
251
|
+
const sourceItineraries = await tx
|
|
252
|
+
.select()
|
|
253
|
+
.from(productItineraries)
|
|
254
|
+
.where(eq(productItineraries.productId, sourceId));
|
|
255
|
+
for (const row of sourceItineraries) {
|
|
256
|
+
const [copy] = await tx
|
|
257
|
+
.insert(productItineraries)
|
|
258
|
+
.values({ ...withoutSystemColumns(row), productId: targetId })
|
|
259
|
+
.returning();
|
|
260
|
+
if (copy)
|
|
261
|
+
itineraryIdMap.set(row.id, copy.id);
|
|
262
|
+
}
|
|
263
|
+
if (sourceItineraries.length === 0) {
|
|
264
|
+
await tx
|
|
265
|
+
.insert(productItineraries)
|
|
266
|
+
.values({ productId: targetId, name: "Default", isDefault: true, sortOrder: 0 });
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const sourceItineraryIds = sourceItineraries.map((row) => row.id);
|
|
270
|
+
const sourceDays = await tx
|
|
271
|
+
.select()
|
|
272
|
+
.from(productDays)
|
|
273
|
+
.where(inArray(productDays.itineraryId, sourceItineraryIds));
|
|
274
|
+
for (const row of sourceDays) {
|
|
275
|
+
const targetItineraryId = itineraryIdMap.get(row.itineraryId);
|
|
276
|
+
if (!targetItineraryId)
|
|
277
|
+
continue;
|
|
278
|
+
const [copy] = await tx
|
|
279
|
+
.insert(productDays)
|
|
280
|
+
.values({ ...withoutSystemColumns(row), itineraryId: targetItineraryId })
|
|
281
|
+
.returning();
|
|
282
|
+
if (copy)
|
|
283
|
+
dayIdMap.set(row.id, copy.id);
|
|
284
|
+
}
|
|
285
|
+
const sourceDayIds = sourceDays.map((row) => row.id);
|
|
286
|
+
if (sourceDayIds.length === 0)
|
|
287
|
+
return;
|
|
288
|
+
const dayServiceRows = await tx
|
|
289
|
+
.select()
|
|
290
|
+
.from(productDayServices)
|
|
291
|
+
.where(inArray(productDayServices.dayId, sourceDayIds));
|
|
292
|
+
for (const row of dayServiceRows) {
|
|
293
|
+
const targetDayId = dayIdMap.get(row.dayId);
|
|
294
|
+
if (!targetDayId)
|
|
295
|
+
continue;
|
|
296
|
+
await tx.insert(productDayServices).values({ ...withoutSystemColumns(row), dayId: targetDayId });
|
|
297
|
+
}
|
|
298
|
+
const dayTranslationRows = await tx
|
|
299
|
+
.select()
|
|
300
|
+
.from(productDayTranslations)
|
|
301
|
+
.where(inArray(productDayTranslations.dayId, sourceDayIds));
|
|
302
|
+
for (const row of dayTranslationRows) {
|
|
303
|
+
const targetDayId = dayIdMap.get(row.dayId);
|
|
304
|
+
if (!targetDayId)
|
|
305
|
+
continue;
|
|
306
|
+
await tx
|
|
307
|
+
.insert(productDayTranslations)
|
|
308
|
+
.values({ ...withoutSystemColumns(row), dayId: targetDayId });
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
async function copyMedia(ctx) {
|
|
312
|
+
const { tx, sourceId, targetId, dayIdMap } = ctx;
|
|
313
|
+
const mediaRows = await tx.select().from(productMedia).where(eq(productMedia.productId, sourceId));
|
|
314
|
+
for (const row of mediaRows) {
|
|
315
|
+
if (row.isBrochure)
|
|
316
|
+
continue;
|
|
317
|
+
const targetDayId = row.dayId ? dayIdMap.get(row.dayId) : null;
|
|
318
|
+
if (row.dayId && !targetDayId)
|
|
319
|
+
continue;
|
|
320
|
+
await tx.insert(productMedia).values({
|
|
321
|
+
...withoutSystemColumns(row),
|
|
322
|
+
productId: targetId,
|
|
323
|
+
dayId: targetDayId,
|
|
324
|
+
isBrochure: false,
|
|
325
|
+
isBrochureCurrent: false,
|
|
326
|
+
brochureVersion: null,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
async function copyExtras(ctx) {
|
|
331
|
+
const { tx, sourceId, targetId, optionIdMap, productExtraIdMap, optionExtraConfigIdMap } = ctx;
|
|
332
|
+
const extraRows = await tx
|
|
333
|
+
.select()
|
|
334
|
+
.from(productExtras)
|
|
335
|
+
.where(eq(productExtras.productId, sourceId));
|
|
336
|
+
for (const row of extraRows) {
|
|
337
|
+
const [copy] = await tx
|
|
338
|
+
.insert(productExtras)
|
|
339
|
+
.values({ ...withoutSystemColumns(row), productId: targetId })
|
|
340
|
+
.returning();
|
|
341
|
+
if (copy)
|
|
342
|
+
productExtraIdMap.set(row.id, copy.id);
|
|
343
|
+
}
|
|
344
|
+
const sourceOptionIds = [...optionIdMap.keys()];
|
|
345
|
+
if (sourceOptionIds.length === 0)
|
|
346
|
+
return;
|
|
347
|
+
const extraConfigRows = await tx
|
|
348
|
+
.select()
|
|
349
|
+
.from(optionExtraConfigs)
|
|
350
|
+
.where(inArray(optionExtraConfigs.optionId, sourceOptionIds));
|
|
351
|
+
for (const row of extraConfigRows) {
|
|
352
|
+
const targetOptionId = optionIdMap.get(row.optionId);
|
|
353
|
+
const targetProductExtraId = productExtraIdMap.get(row.productExtraId);
|
|
354
|
+
if (!targetOptionId || !targetProductExtraId)
|
|
355
|
+
continue;
|
|
356
|
+
const [copy] = await tx
|
|
357
|
+
.insert(optionExtraConfigs)
|
|
358
|
+
.values({
|
|
359
|
+
...withoutSystemColumns(row),
|
|
360
|
+
optionId: targetOptionId,
|
|
361
|
+
productExtraId: targetProductExtraId,
|
|
362
|
+
})
|
|
363
|
+
.returning();
|
|
364
|
+
if (copy)
|
|
365
|
+
optionExtraConfigIdMap.set(row.id, copy.id);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type CloneContext } from "./clone-content.js";
|
|
2
|
+
/**
|
|
3
|
+
* Copies availability (when `copyDepartures`) and the full pricing-rule graph —
|
|
4
|
+
* option price rules → unit price rules (with remapped pricing categories) →
|
|
5
|
+
* tiers, plus start-time / pickup / dropoff / extra rules and departure
|
|
6
|
+
* overrides. Relies on the id remaps populated by {@link copyProductContent}.
|
|
7
|
+
*/
|
|
8
|
+
export declare function copyPricingAndAvailability(ctx: CloneContext): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=clone-pricing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone-pricing.d.ts","sourceRoot":"","sources":["../src/clone-pricing.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,oBAAoB,CAAA;AAE5E;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAQjF"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { availabilityRules, availabilitySlots, availabilityStartTimes, } from "@voyantjs/availability";
|
|
2
|
+
import { departurePriceOverrides, dropoffPriceRules, extraPriceRules, optionPriceRules, optionStartTimeRules, optionUnitPriceRules, optionUnitTiers, pickupPriceRules, } from "@voyantjs/pricing/schema";
|
|
3
|
+
import { eq, inArray } from "drizzle-orm";
|
|
4
|
+
import { withoutSystemColumns } from "./clone-content.js";
|
|
5
|
+
/**
|
|
6
|
+
* Copies availability (when `copyDepartures`) and the full pricing-rule graph —
|
|
7
|
+
* option price rules → unit price rules (with remapped pricing categories) →
|
|
8
|
+
* tiers, plus start-time / pickup / dropoff / extra rules and departure
|
|
9
|
+
* overrides. Relies on the id remaps populated by {@link copyProductContent}.
|
|
10
|
+
*/
|
|
11
|
+
export async function copyPricingAndAvailability(ctx) {
|
|
12
|
+
if (ctx.copyDepartures) {
|
|
13
|
+
await copyAvailability(ctx);
|
|
14
|
+
}
|
|
15
|
+
await copyPriceRules(ctx);
|
|
16
|
+
if (ctx.copyDepartures && ctx.slotIdMap.size > 0) {
|
|
17
|
+
await copyDepartureOverrides(ctx);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function copyAvailability(ctx) {
|
|
21
|
+
const { tx, sourceId, targetId, optionIdMap, itineraryIdMap, startTimeIdMap, ruleIdMap, slotIdMap, } = ctx;
|
|
22
|
+
const startTimeRows = await tx
|
|
23
|
+
.select()
|
|
24
|
+
.from(availabilityStartTimes)
|
|
25
|
+
.where(eq(availabilityStartTimes.productId, sourceId));
|
|
26
|
+
for (const row of startTimeRows) {
|
|
27
|
+
const [copy] = await tx
|
|
28
|
+
.insert(availabilityStartTimes)
|
|
29
|
+
.values({
|
|
30
|
+
...withoutSystemColumns(row),
|
|
31
|
+
productId: targetId,
|
|
32
|
+
optionId: row.optionId ? (optionIdMap.get(row.optionId) ?? null) : null,
|
|
33
|
+
})
|
|
34
|
+
.returning();
|
|
35
|
+
if (copy)
|
|
36
|
+
startTimeIdMap.set(row.id, copy.id);
|
|
37
|
+
}
|
|
38
|
+
const availabilityRuleRows = await tx
|
|
39
|
+
.select()
|
|
40
|
+
.from(availabilityRules)
|
|
41
|
+
.where(eq(availabilityRules.productId, sourceId));
|
|
42
|
+
for (const row of availabilityRuleRows) {
|
|
43
|
+
const [copy] = await tx
|
|
44
|
+
.insert(availabilityRules)
|
|
45
|
+
.values({
|
|
46
|
+
...withoutSystemColumns(row),
|
|
47
|
+
productId: targetId,
|
|
48
|
+
optionId: row.optionId ? (optionIdMap.get(row.optionId) ?? null) : null,
|
|
49
|
+
})
|
|
50
|
+
.returning();
|
|
51
|
+
if (copy)
|
|
52
|
+
ruleIdMap.set(row.id, copy.id);
|
|
53
|
+
}
|
|
54
|
+
const slotRows = await tx
|
|
55
|
+
.select()
|
|
56
|
+
.from(availabilitySlots)
|
|
57
|
+
.where(eq(availabilitySlots.productId, sourceId));
|
|
58
|
+
for (const row of slotRows) {
|
|
59
|
+
const targetItineraryId = row.itineraryId ? (itineraryIdMap.get(row.itineraryId) ?? null) : null;
|
|
60
|
+
const targetOptionId = row.optionId ? (optionIdMap.get(row.optionId) ?? null) : null;
|
|
61
|
+
const targetRuleId = row.availabilityRuleId
|
|
62
|
+
? (ruleIdMap.get(row.availabilityRuleId) ?? null)
|
|
63
|
+
: null;
|
|
64
|
+
const targetStartTimeId = row.startTimeId ? (startTimeIdMap.get(row.startTimeId) ?? null) : null;
|
|
65
|
+
const [copy] = await tx
|
|
66
|
+
.insert(availabilitySlots)
|
|
67
|
+
.values({
|
|
68
|
+
...withoutSystemColumns(row),
|
|
69
|
+
productId: targetId,
|
|
70
|
+
itineraryId: targetItineraryId,
|
|
71
|
+
optionId: targetOptionId,
|
|
72
|
+
availabilityRuleId: targetRuleId,
|
|
73
|
+
startTimeId: targetStartTimeId,
|
|
74
|
+
remainingPax: row.initialPax,
|
|
75
|
+
remainingPickups: row.initialPickups,
|
|
76
|
+
})
|
|
77
|
+
.returning();
|
|
78
|
+
if (copy)
|
|
79
|
+
slotIdMap.set(row.id, copy.id);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function copyPriceRules(ctx) {
|
|
83
|
+
const { tx, targetId, optionIdMap, unitIdMap, startTimeIdMap, optionPriceRuleIdMap, optionUnitPriceRuleIdMap, pricingCategoryIdMap, productExtraIdMap, optionExtraConfigIdMap, } = ctx;
|
|
84
|
+
const sourceOptionIds = [...optionIdMap.keys()];
|
|
85
|
+
if (sourceOptionIds.length === 0)
|
|
86
|
+
return;
|
|
87
|
+
const optionPriceRuleRows = await tx
|
|
88
|
+
.select()
|
|
89
|
+
.from(optionPriceRules)
|
|
90
|
+
.where(inArray(optionPriceRules.optionId, sourceOptionIds));
|
|
91
|
+
for (const row of optionPriceRuleRows) {
|
|
92
|
+
const targetOptionId = optionIdMap.get(row.optionId);
|
|
93
|
+
if (!targetOptionId)
|
|
94
|
+
continue;
|
|
95
|
+
const [copy] = await tx
|
|
96
|
+
.insert(optionPriceRules)
|
|
97
|
+
.values({ ...withoutSystemColumns(row), productId: targetId, optionId: targetOptionId })
|
|
98
|
+
.returning();
|
|
99
|
+
if (copy)
|
|
100
|
+
optionPriceRuleIdMap.set(row.id, copy.id);
|
|
101
|
+
}
|
|
102
|
+
const sourceOptionPriceRuleIds = optionPriceRuleRows.map((row) => row.id);
|
|
103
|
+
if (sourceOptionPriceRuleIds.length === 0)
|
|
104
|
+
return;
|
|
105
|
+
const optionUnitPriceRuleRows = await tx
|
|
106
|
+
.select()
|
|
107
|
+
.from(optionUnitPriceRules)
|
|
108
|
+
.where(inArray(optionUnitPriceRules.optionPriceRuleId, sourceOptionPriceRuleIds));
|
|
109
|
+
for (const row of optionUnitPriceRuleRows) {
|
|
110
|
+
const targetPriceRuleId = optionPriceRuleIdMap.get(row.optionPriceRuleId);
|
|
111
|
+
const targetOptionId = optionIdMap.get(row.optionId);
|
|
112
|
+
const targetUnitId = unitIdMap.get(row.unitId);
|
|
113
|
+
const targetPricingCategoryId = row.pricingCategoryId
|
|
114
|
+
? (pricingCategoryIdMap.get(row.pricingCategoryId) ?? null)
|
|
115
|
+
: null;
|
|
116
|
+
if (!targetPriceRuleId || !targetOptionId || !targetUnitId)
|
|
117
|
+
continue;
|
|
118
|
+
if (row.pricingCategoryId && !targetPricingCategoryId)
|
|
119
|
+
continue;
|
|
120
|
+
const [copy] = await tx
|
|
121
|
+
.insert(optionUnitPriceRules)
|
|
122
|
+
.values({
|
|
123
|
+
...withoutSystemColumns(row),
|
|
124
|
+
optionPriceRuleId: targetPriceRuleId,
|
|
125
|
+
optionId: targetOptionId,
|
|
126
|
+
unitId: targetUnitId,
|
|
127
|
+
pricingCategoryId: targetPricingCategoryId,
|
|
128
|
+
})
|
|
129
|
+
.returning();
|
|
130
|
+
if (copy)
|
|
131
|
+
optionUnitPriceRuleIdMap.set(row.id, copy.id);
|
|
132
|
+
}
|
|
133
|
+
const sourceOptionUnitPriceRuleIds = optionUnitPriceRuleRows.map((row) => row.id);
|
|
134
|
+
if (sourceOptionUnitPriceRuleIds.length > 0) {
|
|
135
|
+
const tierRows = await tx
|
|
136
|
+
.select()
|
|
137
|
+
.from(optionUnitTiers)
|
|
138
|
+
.where(inArray(optionUnitTiers.optionUnitPriceRuleId, sourceOptionUnitPriceRuleIds));
|
|
139
|
+
for (const row of tierRows) {
|
|
140
|
+
const targetUnitPriceRuleId = optionUnitPriceRuleIdMap.get(row.optionUnitPriceRuleId);
|
|
141
|
+
if (!targetUnitPriceRuleId)
|
|
142
|
+
continue;
|
|
143
|
+
await tx
|
|
144
|
+
.insert(optionUnitTiers)
|
|
145
|
+
.values({ ...withoutSystemColumns(row), optionUnitPriceRuleId: targetUnitPriceRuleId });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const startRuleRows = await tx
|
|
149
|
+
.select()
|
|
150
|
+
.from(optionStartTimeRules)
|
|
151
|
+
.where(inArray(optionStartTimeRules.optionPriceRuleId, sourceOptionPriceRuleIds));
|
|
152
|
+
for (const row of startRuleRows) {
|
|
153
|
+
const targetPriceRuleId = optionPriceRuleIdMap.get(row.optionPriceRuleId);
|
|
154
|
+
const targetOptionId = optionIdMap.get(row.optionId);
|
|
155
|
+
const targetStartTimeId = startTimeIdMap.get(row.startTimeId);
|
|
156
|
+
if (!targetPriceRuleId || !targetOptionId || !targetStartTimeId)
|
|
157
|
+
continue;
|
|
158
|
+
await tx.insert(optionStartTimeRules).values({
|
|
159
|
+
...withoutSystemColumns(row),
|
|
160
|
+
optionPriceRuleId: targetPriceRuleId,
|
|
161
|
+
optionId: targetOptionId,
|
|
162
|
+
startTimeId: targetStartTimeId,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const pickupPriceRuleRows = await tx
|
|
166
|
+
.select()
|
|
167
|
+
.from(pickupPriceRules)
|
|
168
|
+
.where(inArray(pickupPriceRules.optionPriceRuleId, sourceOptionPriceRuleIds));
|
|
169
|
+
for (const row of pickupPriceRuleRows) {
|
|
170
|
+
const targetPriceRuleId = optionPriceRuleIdMap.get(row.optionPriceRuleId);
|
|
171
|
+
const targetOptionId = optionIdMap.get(row.optionId);
|
|
172
|
+
if (!targetPriceRuleId || !targetOptionId)
|
|
173
|
+
continue;
|
|
174
|
+
await tx.insert(pickupPriceRules).values({
|
|
175
|
+
...withoutSystemColumns(row),
|
|
176
|
+
optionPriceRuleId: targetPriceRuleId,
|
|
177
|
+
optionId: targetOptionId,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const dropoffPriceRuleRows = await tx
|
|
181
|
+
.select()
|
|
182
|
+
.from(dropoffPriceRules)
|
|
183
|
+
.where(inArray(dropoffPriceRules.optionPriceRuleId, sourceOptionPriceRuleIds));
|
|
184
|
+
for (const row of dropoffPriceRuleRows) {
|
|
185
|
+
const targetPriceRuleId = optionPriceRuleIdMap.get(row.optionPriceRuleId);
|
|
186
|
+
const targetOptionId = optionIdMap.get(row.optionId);
|
|
187
|
+
if (!targetPriceRuleId || !targetOptionId)
|
|
188
|
+
continue;
|
|
189
|
+
await tx.insert(dropoffPriceRules).values({
|
|
190
|
+
...withoutSystemColumns(row),
|
|
191
|
+
optionPriceRuleId: targetPriceRuleId,
|
|
192
|
+
optionId: targetOptionId,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
const extraPriceRuleRows = await tx
|
|
196
|
+
.select()
|
|
197
|
+
.from(extraPriceRules)
|
|
198
|
+
.where(inArray(extraPriceRules.optionPriceRuleId, sourceOptionPriceRuleIds));
|
|
199
|
+
for (const row of extraPriceRuleRows) {
|
|
200
|
+
const targetPriceRuleId = optionPriceRuleIdMap.get(row.optionPriceRuleId);
|
|
201
|
+
const targetOptionId = optionIdMap.get(row.optionId);
|
|
202
|
+
const targetProductExtraId = row.productExtraId
|
|
203
|
+
? (productExtraIdMap.get(row.productExtraId) ?? null)
|
|
204
|
+
: null;
|
|
205
|
+
const targetOptionExtraConfigId = row.optionExtraConfigId
|
|
206
|
+
? (optionExtraConfigIdMap.get(row.optionExtraConfigId) ?? null)
|
|
207
|
+
: null;
|
|
208
|
+
if (!targetPriceRuleId || !targetOptionId)
|
|
209
|
+
continue;
|
|
210
|
+
if (row.productExtraId && !targetProductExtraId)
|
|
211
|
+
continue;
|
|
212
|
+
if (row.optionExtraConfigId && !targetOptionExtraConfigId)
|
|
213
|
+
continue;
|
|
214
|
+
await tx.insert(extraPriceRules).values({
|
|
215
|
+
...withoutSystemColumns(row),
|
|
216
|
+
optionPriceRuleId: targetPriceRuleId,
|
|
217
|
+
optionId: targetOptionId,
|
|
218
|
+
productExtraId: targetProductExtraId,
|
|
219
|
+
optionExtraConfigId: targetOptionExtraConfigId,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async function copyDepartureOverrides(ctx) {
|
|
224
|
+
const { tx, optionIdMap, unitIdMap, slotIdMap } = ctx;
|
|
225
|
+
const overrideRows = await tx
|
|
226
|
+
.select()
|
|
227
|
+
.from(departurePriceOverrides)
|
|
228
|
+
.where(inArray(departurePriceOverrides.departureId, [...slotIdMap.keys()]));
|
|
229
|
+
for (const row of overrideRows) {
|
|
230
|
+
const targetDepartureId = slotIdMap.get(row.departureId);
|
|
231
|
+
const targetOptionId = optionIdMap.get(row.optionId);
|
|
232
|
+
const targetUnitId = unitIdMap.get(row.optionUnitId);
|
|
233
|
+
if (!targetDepartureId || !targetOptionId || !targetUnitId)
|
|
234
|
+
continue;
|
|
235
|
+
await tx.insert(departurePriceOverrides).values({
|
|
236
|
+
...withoutSystemColumns(row),
|
|
237
|
+
departureId: targetDepartureId,
|
|
238
|
+
optionId: targetOptionId,
|
|
239
|
+
optionUnitId: targetUnitId,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
package/dist/clone.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../src/clone.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,YAAY,GACb,MAAM,oCAAoC,CAAA"}
|
package/dist/clone.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cloneProduct, } from "@voyant-travel/inventory/authoring";
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAA"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AuthoringValidationError } from "@voyant-travel/inventory/authoring";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,8CAA8C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { catalogAuthoringExtension, catalogAuthoringRoutes, inventoryAuthoringExtension, inventoryAuthoringRoutes, } from "@voyant-travel/inventory/authoring/extension";
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,eAAO,MAAM,sBAAsB,EAAE,MAEpC,CAAA;AAED,cAAc,oCAAoC,CAAA"}
|
package/dist/index.js
ADDED
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,cAAc,2CAA2C,CAAA"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@voyant-travel/inventory/authoring/schema";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,cAAc,GACf,MAAM,oCAAoC,CAAA"}
|
package/dist/service.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { composeProduct, } from "@voyant-travel/inventory/authoring";
|
package/dist/spec.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../src/spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,sBAAsB,GACvB,MAAM,yCAAyC,CAAA"}
|
package/dist/spec.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { productGraphSpecSchema, } from "@voyant-travel/inventory/authoring/spec";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA"}
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { validateProductGraph } from "@voyant-travel/inventory/authoring";
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyant-travel/catalog-authoring",
|
|
3
|
+
"version": "0.106.18",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./schema": {
|
|
13
|
+
"types": "./dist/schema.d.ts",
|
|
14
|
+
"import": "./dist/schema.js",
|
|
15
|
+
"default": "./dist/schema.js"
|
|
16
|
+
},
|
|
17
|
+
"./spec": {
|
|
18
|
+
"types": "./dist/spec.d.ts",
|
|
19
|
+
"import": "./dist/spec.js",
|
|
20
|
+
"default": "./dist/spec.js"
|
|
21
|
+
},
|
|
22
|
+
"./extension": {
|
|
23
|
+
"types": "./dist/extension.d.ts",
|
|
24
|
+
"import": "./dist/extension.js",
|
|
25
|
+
"default": "./dist/extension.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@voyant-travel/core": "^0.109.0",
|
|
30
|
+
"@voyant-travel/inventory": "^0.1.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"drizzle-orm": "^0.45.2",
|
|
34
|
+
"hono": "^4.12.10",
|
|
35
|
+
"typescript": "^6.0.2",
|
|
36
|
+
"zod": "^4.3.6",
|
|
37
|
+
"@voyant-travel/operations": "^0.0.0",
|
|
38
|
+
"@voyant-travel/hono": "^0.109.1",
|
|
39
|
+
"@voyant-travel/db": "^0.108.0",
|
|
40
|
+
"@voyant-travel/commerce": "^0.1.0",
|
|
41
|
+
"@voyant-travel/inventory": "^0.1.0",
|
|
42
|
+
"@voyant-travel/voyant-typescript-config": "^0.1.0",
|
|
43
|
+
"@voyant-travel/voyant-test-utils": "^0.1.0"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
],
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/voyant-travel/voyant.git",
|
|
54
|
+
"directory": "packages/catalog-authoring"
|
|
55
|
+
},
|
|
56
|
+
"voyant": {
|
|
57
|
+
"schema": "./schema",
|
|
58
|
+
"requiresSchemas": [
|
|
59
|
+
"@voyant-travel/db",
|
|
60
|
+
"@voyant-travel/inventory",
|
|
61
|
+
"@voyant-travel/commerce",
|
|
62
|
+
"@voyant-travel/operations"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"typecheck": "tsc --noEmit",
|
|
67
|
+
"lint": "biome check src/",
|
|
68
|
+
"test": "vitest run",
|
|
69
|
+
"build": "tsc -p tsconfig.json",
|
|
70
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
71
|
+
},
|
|
72
|
+
"main": "./dist/index.js",
|
|
73
|
+
"types": "./dist/index.d.ts"
|
|
74
|
+
}
|