@managesome/eposmatic-toolkit 0.4.90 → 0.4.92
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/esm/constants/ENUMS.js +1 -0
- package/esm/constants/enums/storage.js +23 -0
- package/esm/helpers/index.js +1 -0
- package/esm/helpers/storage/index.js +1 -0
- package/esm/helpers/storage/upload-paths.js +384 -0
- package/esm/schemas/models/index.js +1 -0
- package/esm/schemas/models/pending_uploads.js +102 -0
- package/esm/schemas/types/index.js +1 -0
- package/esm/schemas/types/pending_uploads.js +1 -0
- package/lib/constants/ENUMS.d.ts +1 -0
- package/lib/constants/ENUMS.js +1 -0
- package/lib/constants/enums/storage.d.ts +21 -0
- package/lib/constants/enums/storage.js +26 -0
- package/lib/helpers/index.d.ts +1 -0
- package/lib/helpers/index.js +1 -0
- package/lib/helpers/storage/index.d.ts +1 -0
- package/lib/helpers/storage/index.js +17 -0
- package/lib/helpers/storage/upload-paths.d.ts +117 -0
- package/lib/helpers/storage/upload-paths.js +394 -0
- package/lib/schemas/models/index.d.ts +1 -0
- package/lib/schemas/models/index.js +1 -0
- package/lib/schemas/models/pending_uploads.d.ts +118 -0
- package/lib/schemas/models/pending_uploads.js +105 -0
- package/lib/schemas/models/tenant_hr_employees.d.ts +3 -3
- package/lib/schemas/types/index.d.ts +1 -0
- package/lib/schemas/types/index.js +1 -0
- package/lib/schemas/types/pending_uploads.d.ts +30 -0
- package/lib/schemas/types/pending_uploads.js +2 -0
- package/lib/tests/pending-uploads-schema.test.d.ts +1 -0
- package/lib/tests/pending-uploads-schema.test.js +79 -0
- package/lib/tests/storage-upload-paths.test.d.ts +1 -0
- package/lib/tests/storage-upload-paths.test.js +198 -0
- package/package.json +1 -1
package/esm/constants/ENUMS.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export var PENDING_UPLOAD_REF_TYPE_ENUM;
|
|
2
|
+
(function (PENDING_UPLOAD_REF_TYPE_ENUM) {
|
|
3
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["TENANT"] = "TENANT";
|
|
4
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["BRAND"] = "BRAND";
|
|
5
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["WAREHOUSE"] = "WAREHOUSE";
|
|
6
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["EMPLOYEE"] = "EMPLOYEE";
|
|
7
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["DELIVERY"] = "DELIVERY";
|
|
8
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["RIDER"] = "RIDER";
|
|
9
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["RESTAURANT"] = "RESTAURANT";
|
|
10
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["EXPENSE"] = "EXPENSE";
|
|
11
|
+
})(PENDING_UPLOAD_REF_TYPE_ENUM || (PENDING_UPLOAD_REF_TYPE_ENUM = {}));
|
|
12
|
+
export const ALL_PENDING_UPLOAD_REF_TYPES = Object.values(PENDING_UPLOAD_REF_TYPE_ENUM);
|
|
13
|
+
/**
|
|
14
|
+
* Delivery proof stage. Enum values are upper-case by enum convention;
|
|
15
|
+
* the path builder lower-cases them into the storage leaf
|
|
16
|
+
* (`pickup_food_image_url.<ext>` / `dropoff_food_image_url.<ext>`).
|
|
17
|
+
*/
|
|
18
|
+
export var PENDING_UPLOAD_STAGE_ENUM;
|
|
19
|
+
(function (PENDING_UPLOAD_STAGE_ENUM) {
|
|
20
|
+
PENDING_UPLOAD_STAGE_ENUM["PICKUP"] = "PICKUP";
|
|
21
|
+
PENDING_UPLOAD_STAGE_ENUM["DROPOFF"] = "DROPOFF";
|
|
22
|
+
})(PENDING_UPLOAD_STAGE_ENUM || (PENDING_UPLOAD_STAGE_ENUM = {}));
|
|
23
|
+
export const ALL_PENDING_UPLOAD_STAGES = Object.values(PENDING_UPLOAD_STAGE_ENUM);
|
package/esm/helpers/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './upload-paths';
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-owned Cloud Storage upload path registry.
|
|
3
|
+
*
|
|
4
|
+
* The client sends a `kind` plus entity ids and file metadata. This module is
|
|
5
|
+
* the only place that turns those inputs into a bucket-relative object path.
|
|
6
|
+
* Nothing here performs I/O, so both backend services can import it and the
|
|
7
|
+
* toolkit build stays usable in browser contexts.
|
|
8
|
+
*
|
|
9
|
+
* Security invariants:
|
|
10
|
+
* - every kind is in a closed registry;
|
|
11
|
+
* - every client-supplied id is a single, validated path segment;
|
|
12
|
+
* - only `images/` and `documents/` roots are reachable;
|
|
13
|
+
* - the final path is re-validated after construction.
|
|
14
|
+
*/
|
|
15
|
+
import { PENDING_UPLOAD_REF_TYPE_ENUM, PENDING_UPLOAD_STAGE_ENUM } from '../../constants/enums/storage';
|
|
16
|
+
export const IMAGE_MAX_BYTES = 5 * 1024 * 1024;
|
|
17
|
+
export const DOCUMENT_MAX_BYTES = 10 * 1024 * 1024;
|
|
18
|
+
export const IMAGE_MIME_EXTENSIONS = {
|
|
19
|
+
'image/avif': 'avif',
|
|
20
|
+
'image/gif': 'gif',
|
|
21
|
+
'image/heic': 'heic',
|
|
22
|
+
'image/heif': 'heif',
|
|
23
|
+
'image/jpeg': 'jpeg',
|
|
24
|
+
'image/jpg': 'jpeg',
|
|
25
|
+
'image/png': 'png',
|
|
26
|
+
'image/vnd.microsoft.icon': 'ico',
|
|
27
|
+
'image/webp': 'webp',
|
|
28
|
+
'image/x-icon': 'ico',
|
|
29
|
+
};
|
|
30
|
+
export const DOCUMENT_MIME_EXTENSIONS = {
|
|
31
|
+
'application/msword': ['doc'],
|
|
32
|
+
'application/pdf': ['pdf'],
|
|
33
|
+
'application/vnd.ms-excel': ['xls'],
|
|
34
|
+
'application/vnd.ms-powerpoint': ['ppt'],
|
|
35
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation': ['pptx'],
|
|
36
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': ['xlsx'],
|
|
37
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': ['docx'],
|
|
38
|
+
'image/heic': ['heic'],
|
|
39
|
+
'image/jpeg': ['jpg', 'jpeg'],
|
|
40
|
+
'image/png': ['png'],
|
|
41
|
+
'image/webp': ['webp'],
|
|
42
|
+
'text/csv': ['csv'],
|
|
43
|
+
'text/plain': ['txt'],
|
|
44
|
+
};
|
|
45
|
+
export const STORAGE_UPLOAD_KIND = {
|
|
46
|
+
BRAND_CATEGORY_BANNER: 'brand.category_banner',
|
|
47
|
+
BRAND_CATEGORY_IMAGE: 'brand.category',
|
|
48
|
+
BRAND_HALF_HALF_IMAGE: 'brand.halfhalf',
|
|
49
|
+
BRAND_IMAGE: 'brand.image',
|
|
50
|
+
BRAND_ITEM_IMAGE: 'brand.item',
|
|
51
|
+
BRAND_OFFER_IMAGE: 'brand.offer',
|
|
52
|
+
BRAND_SPECIAL_IMAGE: 'brand.special',
|
|
53
|
+
BRAND_WAREHOUSE_CATEGORY_IMAGE: 'brand.warehouse.category',
|
|
54
|
+
BRAND_WAREHOUSE_ITEM_IMAGE: 'brand.warehouse.item',
|
|
55
|
+
DELIVERY_PROOF: 'delivery.proof',
|
|
56
|
+
DOCUMENT_HR: 'document.hr',
|
|
57
|
+
DOCUMENT_POLICY: 'document.policy',
|
|
58
|
+
INTERNAL_EXPENSE_IMAGE: 'internal.expense',
|
|
59
|
+
INTERNAL_RESTAURANT_IMAGE: 'internal.restaurant',
|
|
60
|
+
RIDER_IMAGE: 'rider.image',
|
|
61
|
+
TENANT_DEPARTMENT_IMAGE: 'tenant.department',
|
|
62
|
+
TENANT_DIGITAL_MENU: 'tenant.digital_menu',
|
|
63
|
+
TENANT_EXPENSE_IMAGE: 'tenant.expense',
|
|
64
|
+
TENANT_IMAGE: 'tenant.image',
|
|
65
|
+
TENANT_INVENTORY_IMAGE: 'tenant.inventory',
|
|
66
|
+
TENANT_MARKETING_IMAGE: 'tenant.marketing',
|
|
67
|
+
TENANT_SLIDER: 'tenant.slider',
|
|
68
|
+
TENANT_STAFF_IMAGE: 'tenant.staff',
|
|
69
|
+
TENANT_WEB_COVER: 'tenant.web_cover',
|
|
70
|
+
TENANT_WEB_FAVICON: 'tenant.web_favicon',
|
|
71
|
+
WAREHOUSE_EXPENSE_IMAGE: 'warehouse.expense',
|
|
72
|
+
WAREHOUSE_IMAGE: 'warehouse.image',
|
|
73
|
+
WAREHOUSE_INVENTORY_IMAGE: 'warehouse.inventory',
|
|
74
|
+
WAREHOUSE_STAFF_IMAGE: 'warehouse.staff',
|
|
75
|
+
};
|
|
76
|
+
export class StorageUploadValidationError extends Error {
|
|
77
|
+
constructor(code, message) {
|
|
78
|
+
super(message);
|
|
79
|
+
this.name = 'StorageUploadValidationError';
|
|
80
|
+
this.code = code;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const ID_FIELDS = [
|
|
84
|
+
'brand_id',
|
|
85
|
+
'tenant_id',
|
|
86
|
+
'warehouse_id',
|
|
87
|
+
'employee_id',
|
|
88
|
+
'delivery_id',
|
|
89
|
+
'record_id',
|
|
90
|
+
'resource_id',
|
|
91
|
+
];
|
|
92
|
+
const SEGMENT_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
93
|
+
const FINAL_PATH_PATTERN = /^[A-Za-z0-9._/-]+$/;
|
|
94
|
+
const UUID_V4_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
95
|
+
function fail(code, message) {
|
|
96
|
+
throw new StorageUploadValidationError(code, message);
|
|
97
|
+
}
|
|
98
|
+
function requireId(ids, field) {
|
|
99
|
+
const value = ids[field];
|
|
100
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
101
|
+
fail('MISSING_FIELD', `Missing required storage id: ${field}`);
|
|
102
|
+
}
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
function assertSegment(value, field) {
|
|
106
|
+
if (typeof value !== 'string' || !SEGMENT_PATTERN.test(value) || value.includes('..')) {
|
|
107
|
+
fail('INVALID_ID', `Invalid storage path segment for ${field}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function assertFinalPath(path) {
|
|
111
|
+
if (!path.startsWith('images/') && !path.startsWith('documents/')) {
|
|
112
|
+
fail('INVALID_PATH', 'Storage path must start with images/ or documents/');
|
|
113
|
+
}
|
|
114
|
+
if (path.length === 0 || path.length > 1024) {
|
|
115
|
+
fail('INVALID_PATH', 'Storage path length is out of bounds');
|
|
116
|
+
}
|
|
117
|
+
if (path.includes('//') || path.includes('..') || path.includes('?') || path.includes('#')) {
|
|
118
|
+
fail('INVALID_PATH', 'Storage path contains a forbidden sequence');
|
|
119
|
+
}
|
|
120
|
+
if (!FINAL_PATH_PATTERN.test(path)) {
|
|
121
|
+
fail('INVALID_PATH', 'Storage path contains forbidden characters');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function assertStage(stage) {
|
|
125
|
+
if (stage === PENDING_UPLOAD_STAGE_ENUM.PICKUP || stage === PENDING_UPLOAD_STAGE_ENUM.DROPOFF) {
|
|
126
|
+
return stage;
|
|
127
|
+
}
|
|
128
|
+
return fail('INVALID_STAGE', 'stage must be PICKUP or DROPOFF');
|
|
129
|
+
}
|
|
130
|
+
function assertUuid(uuid) {
|
|
131
|
+
if (typeof uuid !== 'string' || !UUID_V4_PATTERN.test(uuid)) {
|
|
132
|
+
fail('INVALID_UUID', 'A valid server-generated UUID is required for this kind');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export function normalizeStorageMime(mime) {
|
|
136
|
+
if (typeof mime !== 'string') {
|
|
137
|
+
fail('INVALID_MIME', 'mime must be a string');
|
|
138
|
+
}
|
|
139
|
+
return mime.split(';')[0].trim().toLowerCase();
|
|
140
|
+
}
|
|
141
|
+
function imageExtension(mime) {
|
|
142
|
+
const extension = IMAGE_MIME_EXTENSIONS[mime];
|
|
143
|
+
if (!extension) {
|
|
144
|
+
fail('INVALID_MIME', `Unsupported image mime type: ${mime}`);
|
|
145
|
+
}
|
|
146
|
+
return extension;
|
|
147
|
+
}
|
|
148
|
+
function filenameExtension(filename, mime) {
|
|
149
|
+
const allowed = DOCUMENT_MIME_EXTENSIONS[mime];
|
|
150
|
+
if (!allowed) {
|
|
151
|
+
fail('INVALID_MIME', `Unsupported document mime type: ${mime}`);
|
|
152
|
+
}
|
|
153
|
+
const cleaned = filename.split('?')[0].split('#')[0].replace(/\\/g, '/');
|
|
154
|
+
const base = cleaned.slice(cleaned.lastIndexOf('/') + 1);
|
|
155
|
+
if (!base || base.startsWith('.') || base.includes('..')) {
|
|
156
|
+
fail('INVALID_FILENAME', 'Invalid document filename');
|
|
157
|
+
}
|
|
158
|
+
const match = /\.([A-Za-z0-9]{1,8})$/.exec(base);
|
|
159
|
+
if (!match) {
|
|
160
|
+
fail('INVALID_FILENAME', 'Document filename has no usable extension');
|
|
161
|
+
}
|
|
162
|
+
const extension = match[1].toLowerCase();
|
|
163
|
+
if (!allowed.includes(extension)) {
|
|
164
|
+
fail('INVALID_FILENAME', `Filename extension .${extension} does not match ${mime}`);
|
|
165
|
+
}
|
|
166
|
+
return extension;
|
|
167
|
+
}
|
|
168
|
+
function resolveExtension(definition, mime, filename) {
|
|
169
|
+
if (definition.extension === 'mime') {
|
|
170
|
+
if (definition.media !== 'image') {
|
|
171
|
+
fail('INVALID_MIME', 'Mime-derived extensions are only allowed for images');
|
|
172
|
+
}
|
|
173
|
+
return `.${imageExtension(mime)}`;
|
|
174
|
+
}
|
|
175
|
+
if (typeof filename !== 'string' || filename.length === 0) {
|
|
176
|
+
fail('MISSING_FIELD', 'filename is required for this kind');
|
|
177
|
+
}
|
|
178
|
+
return `.${filenameExtension(filename, mime)}`;
|
|
179
|
+
}
|
|
180
|
+
function imageDefinition(kind, owner, identities, routes, requiredIds, build, options) {
|
|
181
|
+
return {
|
|
182
|
+
kind,
|
|
183
|
+
routes,
|
|
184
|
+
owner,
|
|
185
|
+
identities,
|
|
186
|
+
media: 'image',
|
|
187
|
+
maxBytes: IMAGE_MAX_BYTES,
|
|
188
|
+
extension: 'mime',
|
|
189
|
+
...options,
|
|
190
|
+
requiredIds,
|
|
191
|
+
build,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function documentDefinition(kind, requiredIds, build) {
|
|
195
|
+
return {
|
|
196
|
+
kind,
|
|
197
|
+
routes: ['items'],
|
|
198
|
+
owner: 'document',
|
|
199
|
+
identities: ['tenant_staff_hr'],
|
|
200
|
+
media: 'document',
|
|
201
|
+
maxBytes: DOCUMENT_MAX_BYTES,
|
|
202
|
+
extension: 'filename',
|
|
203
|
+
leaf: 'uuid',
|
|
204
|
+
requiredIds,
|
|
205
|
+
build,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const FIXED_IMAGE_NAME = 'image_url';
|
|
209
|
+
const recordBaseName = (ids) => requireId(ids, 'record_id');
|
|
210
|
+
const STORAGE_UPLOAD_DEFINITIONS = {
|
|
211
|
+
[STORAGE_UPLOAD_KIND.BRAND_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.BRAND_IMAGE, 'brand', ['tenant_staff', 'internal'], ['items'], ['brand_id'], (ids, fileName) => ['images', 'brands', requireId(ids, 'brand_id'), fileName].join('/'), { baseName: () => FIXED_IMAGE_NAME, leaf: 'fixed' }),
|
|
212
|
+
[STORAGE_UPLOAD_KIND.BRAND_CATEGORY_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.BRAND_CATEGORY_IMAGE, 'brand', ['tenant_staff', 'internal'], ['items'], ['brand_id', 'record_id'], (ids, fileName) => ['images', 'brands', requireId(ids, 'brand_id'), 'categories', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
213
|
+
[STORAGE_UPLOAD_KIND.BRAND_CATEGORY_BANNER]: imageDefinition(STORAGE_UPLOAD_KIND.BRAND_CATEGORY_BANNER, 'brand', ['tenant_staff', 'internal'], ['items'], ['brand_id', 'record_id'], (ids, fileName) => ['images', 'brands', requireId(ids, 'brand_id'), 'categories-banner', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
214
|
+
[STORAGE_UPLOAD_KIND.BRAND_ITEM_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.BRAND_ITEM_IMAGE, 'brand', ['tenant_staff', 'internal'], ['items'], ['brand_id', 'record_id'], (ids, fileName) => ['images', 'brands', requireId(ids, 'brand_id'), 'items', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
215
|
+
[STORAGE_UPLOAD_KIND.BRAND_OFFER_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.BRAND_OFFER_IMAGE, 'brand', ['tenant_staff', 'internal'], ['items'], ['brand_id', 'record_id'], (ids, fileName) => ['images', 'brands', requireId(ids, 'brand_id'), 'offers', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
216
|
+
[STORAGE_UPLOAD_KIND.BRAND_SPECIAL_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.BRAND_SPECIAL_IMAGE, 'brand', ['tenant_staff', 'internal'], ['items'], ['brand_id', 'record_id'], (ids, fileName) => ['images', 'brands', requireId(ids, 'brand_id'), 'specials', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
217
|
+
[STORAGE_UPLOAD_KIND.BRAND_HALF_HALF_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.BRAND_HALF_HALF_IMAGE, 'brand', ['tenant_staff', 'internal'], ['items'], ['brand_id', 'record_id'], (ids, fileName) => ['images', 'brands', requireId(ids, 'brand_id'), 'halfhalf', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
218
|
+
[STORAGE_UPLOAD_KIND.BRAND_WAREHOUSE_CATEGORY_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.BRAND_WAREHOUSE_CATEGORY_IMAGE, 'brand', ['warehouse_staff', 'internal'], ['items', 'operations'], ['brand_id', 'record_id'], (ids, fileName) => ['images', 'brands', requireId(ids, 'brand_id'), 'warehouse-categories', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
219
|
+
[STORAGE_UPLOAD_KIND.BRAND_WAREHOUSE_ITEM_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.BRAND_WAREHOUSE_ITEM_IMAGE, 'brand', ['warehouse_staff', 'internal'], ['items', 'operations'], ['brand_id', 'record_id'], (ids, fileName) => ['images', 'brands', requireId(ids, 'brand_id'), 'warehouse-items', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
220
|
+
[STORAGE_UPLOAD_KIND.TENANT_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.TENANT_IMAGE, 'tenant', ['tenant_staff', 'internal'], ['items'], ['tenant_id'], (ids, fileName) => ['images', 'tenants', requireId(ids, 'tenant_id'), fileName].join('/'), { baseName: () => FIXED_IMAGE_NAME, leaf: 'fixed' }),
|
|
221
|
+
[STORAGE_UPLOAD_KIND.TENANT_WEB_COVER]: imageDefinition(STORAGE_UPLOAD_KIND.TENANT_WEB_COVER, 'tenant', ['tenant_staff', 'internal'], ['items'], ['tenant_id'], (ids, fileName) => ['images', 'tenants', requireId(ids, 'tenant_id'), fileName].join('/'), { baseName: () => 'web_cover', leaf: 'fixed' }),
|
|
222
|
+
[STORAGE_UPLOAD_KIND.TENANT_WEB_FAVICON]: imageDefinition(STORAGE_UPLOAD_KIND.TENANT_WEB_FAVICON, 'tenant', ['tenant_staff', 'internal'], ['items'], ['tenant_id'], (ids, fileName) => ['images', 'tenants', requireId(ids, 'tenant_id'), fileName].join('/'), { baseName: () => 'web_favicon', leaf: 'fixed' }),
|
|
223
|
+
[STORAGE_UPLOAD_KIND.TENANT_DIGITAL_MENU]: imageDefinition(STORAGE_UPLOAD_KIND.TENANT_DIGITAL_MENU, 'tenant', ['tenant_staff', 'internal'], ['items'], ['tenant_id'], (ids, fileName) => ['images', 'tenants', requireId(ids, 'tenant_id'), 'digital-menu', fileName].join('/'), { leaf: 'uuid' }),
|
|
224
|
+
[STORAGE_UPLOAD_KIND.TENANT_SLIDER]: imageDefinition(STORAGE_UPLOAD_KIND.TENANT_SLIDER, 'tenant', ['tenant_staff', 'internal'], ['items'], ['tenant_id'], (ids, fileName) => ['images', 'tenants', requireId(ids, 'tenant_id'), 'sliders', fileName].join('/'), { leaf: 'uuid' }),
|
|
225
|
+
[STORAGE_UPLOAD_KIND.TENANT_STAFF_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.TENANT_STAFF_IMAGE, 'tenant', ['tenant_staff', 'internal'], ['items'], ['tenant_id', 'record_id'], (ids, fileName) => ['images', 'tenants', requireId(ids, 'tenant_id'), 'staff', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
226
|
+
[STORAGE_UPLOAD_KIND.TENANT_MARKETING_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.TENANT_MARKETING_IMAGE, 'tenant', ['tenant_staff', 'internal'], ['items'], ['tenant_id', 'record_id'], (ids, fileName) => ['images', 'tenants', requireId(ids, 'tenant_id'), 'marketing', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
227
|
+
[STORAGE_UPLOAD_KIND.TENANT_EXPENSE_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.TENANT_EXPENSE_IMAGE, 'tenant', ['tenant_staff', 'internal'], ['items'], ['tenant_id', 'record_id'], (ids, fileName) => ['images', 'tenants', requireId(ids, 'tenant_id'), 'expense-details', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
228
|
+
[STORAGE_UPLOAD_KIND.TENANT_INVENTORY_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.TENANT_INVENTORY_IMAGE, 'tenant', ['tenant_staff', 'internal'], ['items'], ['tenant_id', 'record_id'], (ids, fileName) => ['images', 'tenants', requireId(ids, 'tenant_id'), 'inventory', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
229
|
+
[STORAGE_UPLOAD_KIND.TENANT_DEPARTMENT_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.TENANT_DEPARTMENT_IMAGE, 'tenant', ['tenant_staff', 'internal'], ['items'], ['tenant_id', 'record_id'], (ids, fileName) => ['images', 'tenants', requireId(ids, 'tenant_id'), 'departments', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
230
|
+
[STORAGE_UPLOAD_KIND.WAREHOUSE_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.WAREHOUSE_IMAGE, 'warehouse', ['warehouse_staff', 'internal'], ['items', 'operations'], ['warehouse_id'], (ids, fileName) => ['images', 'warehouses', requireId(ids, 'warehouse_id'), fileName].join('/'), { baseName: () => FIXED_IMAGE_NAME, leaf: 'fixed' }),
|
|
231
|
+
[STORAGE_UPLOAD_KIND.WAREHOUSE_STAFF_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.WAREHOUSE_STAFF_IMAGE, 'warehouse', ['warehouse_staff', 'internal'], ['items', 'operations'], ['warehouse_id', 'record_id'], (ids, fileName) => ['images', 'warehouses', requireId(ids, 'warehouse_id'), 'staff', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
232
|
+
[STORAGE_UPLOAD_KIND.WAREHOUSE_INVENTORY_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.WAREHOUSE_INVENTORY_IMAGE, 'warehouse', ['warehouse_staff', 'internal'], ['items', 'operations'], ['warehouse_id', 'record_id'], (ids, fileName) => ['images', 'warehouses', requireId(ids, 'warehouse_id'), 'inventory', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
233
|
+
[STORAGE_UPLOAD_KIND.WAREHOUSE_EXPENSE_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.WAREHOUSE_EXPENSE_IMAGE, 'warehouse', ['warehouse_staff', 'internal'], ['items', 'operations'], ['warehouse_id', 'record_id'], (ids, fileName) => ['images', 'warehouses', requireId(ids, 'warehouse_id'), 'warehouse-expense-details', fileName].join('/'), { baseName: recordBaseName, leaf: 'record' }),
|
|
234
|
+
[STORAGE_UPLOAD_KIND.DOCUMENT_HR]: documentDefinition(STORAGE_UPLOAD_KIND.DOCUMENT_HR, ['tenant_id', 'employee_id'], (ids, fileName) => [
|
|
235
|
+
'documents',
|
|
236
|
+
'tenants',
|
|
237
|
+
requireId(ids, 'tenant_id'),
|
|
238
|
+
'hr-documents',
|
|
239
|
+
requireId(ids, 'employee_id'),
|
|
240
|
+
fileName,
|
|
241
|
+
].join('/')),
|
|
242
|
+
[STORAGE_UPLOAD_KIND.DOCUMENT_POLICY]: documentDefinition(STORAGE_UPLOAD_KIND.DOCUMENT_POLICY, ['tenant_id'], (ids, fileName) => ['documents', 'tenants', requireId(ids, 'tenant_id'), 'hr-policies', fileName].join('/')),
|
|
243
|
+
[STORAGE_UPLOAD_KIND.INTERNAL_RESTAURANT_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.INTERNAL_RESTAURANT_IMAGE, 'internal', ['internal'], ['items'], ['resource_id'], (ids, fileName) => ['images', 'restaurants', requireId(ids, 'resource_id'), fileName].join('/'), { baseName: () => FIXED_IMAGE_NAME, leaf: 'fixed' }),
|
|
244
|
+
[STORAGE_UPLOAD_KIND.INTERNAL_EXPENSE_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.INTERNAL_EXPENSE_IMAGE, 'internal', ['internal'], ['items'], ['resource_id'], (ids, fileName) => ['images', 'expenses', requireId(ids, 'resource_id'), fileName].join('/'), { baseName: () => FIXED_IMAGE_NAME, leaf: 'fixed' }),
|
|
245
|
+
[STORAGE_UPLOAD_KIND.RIDER_IMAGE]: imageDefinition(STORAGE_UPLOAD_KIND.RIDER_IMAGE, 'rider', ['rider'], ['riders'], [], (_ids, fileName, uid) => ['images', 'riders', uid, fileName].join('/'), { baseName: () => FIXED_IMAGE_NAME, leaf: 'fixed', requiresUid: true }),
|
|
246
|
+
[STORAGE_UPLOAD_KIND.DELIVERY_PROOF]: imageDefinition(STORAGE_UPLOAD_KIND.DELIVERY_PROOF, 'delivery', ['delivery_rider'], ['riders'], ['delivery_id'], (ids, fileName) => ['images', 'deliveries', requireId(ids, 'delivery_id'), fileName].join('/'), {
|
|
247
|
+
baseName: (ids) => `${assertStage(ids.stage).toLowerCase()}_food_image_url`,
|
|
248
|
+
leaf: 'fixed',
|
|
249
|
+
requiredStage: true,
|
|
250
|
+
}),
|
|
251
|
+
};
|
|
252
|
+
function resolveStorageUploadRef(definition, ids, uid) {
|
|
253
|
+
switch (definition.owner) {
|
|
254
|
+
case 'brand':
|
|
255
|
+
return {
|
|
256
|
+
refType: PENDING_UPLOAD_REF_TYPE_ENUM.BRAND,
|
|
257
|
+
refId: requireId(ids, 'brand_id'),
|
|
258
|
+
};
|
|
259
|
+
case 'tenant':
|
|
260
|
+
return {
|
|
261
|
+
refType: PENDING_UPLOAD_REF_TYPE_ENUM.TENANT,
|
|
262
|
+
refId: requireId(ids, 'tenant_id'),
|
|
263
|
+
};
|
|
264
|
+
case 'warehouse':
|
|
265
|
+
return {
|
|
266
|
+
refType: PENDING_UPLOAD_REF_TYPE_ENUM.WAREHOUSE,
|
|
267
|
+
refId: requireId(ids, 'warehouse_id'),
|
|
268
|
+
};
|
|
269
|
+
case 'document':
|
|
270
|
+
return definition.kind === STORAGE_UPLOAD_KIND.DOCUMENT_HR
|
|
271
|
+
? {
|
|
272
|
+
refType: PENDING_UPLOAD_REF_TYPE_ENUM.EMPLOYEE,
|
|
273
|
+
refId: requireId(ids, 'employee_id'),
|
|
274
|
+
}
|
|
275
|
+
: {
|
|
276
|
+
refType: PENDING_UPLOAD_REF_TYPE_ENUM.TENANT,
|
|
277
|
+
refId: requireId(ids, 'tenant_id'),
|
|
278
|
+
};
|
|
279
|
+
case 'internal':
|
|
280
|
+
return definition.kind === STORAGE_UPLOAD_KIND.INTERNAL_RESTAURANT_IMAGE
|
|
281
|
+
? {
|
|
282
|
+
refType: PENDING_UPLOAD_REF_TYPE_ENUM.RESTAURANT,
|
|
283
|
+
refId: requireId(ids, 'resource_id'),
|
|
284
|
+
}
|
|
285
|
+
: {
|
|
286
|
+
refType: PENDING_UPLOAD_REF_TYPE_ENUM.EXPENSE,
|
|
287
|
+
refId: requireId(ids, 'resource_id'),
|
|
288
|
+
};
|
|
289
|
+
case 'rider':
|
|
290
|
+
return {
|
|
291
|
+
refType: PENDING_UPLOAD_REF_TYPE_ENUM.RIDER,
|
|
292
|
+
refId: uid,
|
|
293
|
+
};
|
|
294
|
+
case 'delivery':
|
|
295
|
+
return {
|
|
296
|
+
refType: PENDING_UPLOAD_REF_TYPE_ENUM.DELIVERY,
|
|
297
|
+
refId: requireId(ids, 'delivery_id'),
|
|
298
|
+
};
|
|
299
|
+
default:
|
|
300
|
+
return fail('INVALID_KIND', `Kind ${definition.kind} has no storage reference`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
export function isStorageUploadKind(value) {
|
|
304
|
+
return typeof value === 'string' && Object.prototype.hasOwnProperty.call(STORAGE_UPLOAD_DEFINITIONS, value);
|
|
305
|
+
}
|
|
306
|
+
export function getStorageUploadDefinition(kind) {
|
|
307
|
+
if (!isStorageUploadKind(kind)) {
|
|
308
|
+
fail('INVALID_KIND', `Unknown storage upload kind: ${String(kind)}`);
|
|
309
|
+
}
|
|
310
|
+
return STORAGE_UPLOAD_DEFINITIONS[kind];
|
|
311
|
+
}
|
|
312
|
+
export function getStorageUploadKinds() {
|
|
313
|
+
return Object.values(STORAGE_UPLOAD_KIND);
|
|
314
|
+
}
|
|
315
|
+
export function getStorageUploadKindsForRoute(route) {
|
|
316
|
+
return getStorageUploadKinds().filter((kind) => STORAGE_UPLOAD_DEFINITIONS[kind].routes.includes(route));
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Builds the bucket-relative object path for a validated upload request.
|
|
320
|
+
*
|
|
321
|
+
* Throws `StorageUploadValidationError` for every caller error. The route
|
|
322
|
+
* should map that error to HTTP 400 (or 415 for an unsupported MIME).
|
|
323
|
+
*/
|
|
324
|
+
export function buildStorageUploadPath(input) {
|
|
325
|
+
const definition = getStorageUploadDefinition(input.kind);
|
|
326
|
+
const ids = input.ids ?? {};
|
|
327
|
+
const mime = normalizeStorageMime(input.mime);
|
|
328
|
+
if (!mime) {
|
|
329
|
+
fail('INVALID_MIME', 'mime is required');
|
|
330
|
+
}
|
|
331
|
+
for (const field of ID_FIELDS) {
|
|
332
|
+
const value = ids[field];
|
|
333
|
+
if (value !== undefined) {
|
|
334
|
+
if (typeof value !== 'string') {
|
|
335
|
+
fail('INVALID_ID', `Invalid storage path segment for ${field}`);
|
|
336
|
+
}
|
|
337
|
+
assertSegment(value, field);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (ids.stage !== undefined) {
|
|
341
|
+
assertStage(ids.stage);
|
|
342
|
+
}
|
|
343
|
+
for (const field of definition.requiredIds) {
|
|
344
|
+
requireId(ids, field);
|
|
345
|
+
}
|
|
346
|
+
if (definition.requiredStage && ids.stage === undefined) {
|
|
347
|
+
fail('MISSING_FIELD', 'stage is required for this kind');
|
|
348
|
+
}
|
|
349
|
+
if (definition.requiresUid) {
|
|
350
|
+
if (!input.uid) {
|
|
351
|
+
fail('MISSING_FIELD', 'uid is required for this kind');
|
|
352
|
+
}
|
|
353
|
+
assertSegment(input.uid, 'uid');
|
|
354
|
+
}
|
|
355
|
+
const extension = resolveExtension(definition, mime, input.filename);
|
|
356
|
+
let base;
|
|
357
|
+
if (definition.leaf === 'uuid') {
|
|
358
|
+
if (!input.uuid) {
|
|
359
|
+
fail('MISSING_FIELD', 'uuid is required for this kind');
|
|
360
|
+
}
|
|
361
|
+
assertUuid(input.uuid);
|
|
362
|
+
base = input.uuid;
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
if (!definition.baseName) {
|
|
366
|
+
fail('INVALID_KIND', `Kind ${definition.kind} has no base name`);
|
|
367
|
+
}
|
|
368
|
+
base = definition.baseName(ids);
|
|
369
|
+
}
|
|
370
|
+
assertSegment(base, 'file name');
|
|
371
|
+
const fileName = `${base}${extension}`;
|
|
372
|
+
const ref = resolveStorageUploadRef(definition, ids, input.uid ?? '');
|
|
373
|
+
assertSegment(ref.refId, 'ref_id');
|
|
374
|
+
const path = definition.build(ids, fileName, input.uid ?? '');
|
|
375
|
+
assertFinalPath(path);
|
|
376
|
+
return {
|
|
377
|
+
path,
|
|
378
|
+
extension,
|
|
379
|
+
maxBytes: definition.maxBytes,
|
|
380
|
+
contentType: mime,
|
|
381
|
+
refType: ref.refType,
|
|
382
|
+
refId: ref.refId,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
@@ -61,6 +61,7 @@ export * from './offers';
|
|
|
61
61
|
export * from './offers_fingerprints';
|
|
62
62
|
export * from './operational_roles';
|
|
63
63
|
export * from './orders';
|
|
64
|
+
export * from './pending_uploads';
|
|
64
65
|
export * from './printer_settings';
|
|
65
66
|
export * from './public_holidays';
|
|
66
67
|
export * from './reservations';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
import { ALL_PENDING_UPLOAD_REF_TYPES, ALL_PENDING_UPLOAD_STAGES } from '../../constants/enums/storage';
|
|
3
|
+
import { STORAGE_UPLOAD_KIND } from '../../helpers/storage/upload-paths';
|
|
4
|
+
export const PENDING_UPLOADS_COLLECTION_NAME = 'pending_uploads';
|
|
5
|
+
/**
|
|
6
|
+
* Ledger for server-signed uploads.
|
|
7
|
+
*
|
|
8
|
+
* Standard collection timestamps: `createdAt` / `updatedAt` (timestamps: true).
|
|
9
|
+
* The TTL index is the audit boundary: rows are retained for 30 days after
|
|
10
|
+
* creation, then removed. A discarded or committed row is kept until then so
|
|
11
|
+
* a late discard/confirm can still answer deterministically.
|
|
12
|
+
*
|
|
13
|
+
* A repeated `/sign` for the same deterministic path supersedes the row with
|
|
14
|
+
* `findOneAndReplace`, so the standard timestamps and lifecycle fields restart
|
|
15
|
+
* for the new attempt.
|
|
16
|
+
*/
|
|
17
|
+
export const PendingUploadSchema = new Schema({
|
|
18
|
+
path: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true,
|
|
21
|
+
immutable: true,
|
|
22
|
+
},
|
|
23
|
+
uid: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
kind: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true,
|
|
30
|
+
enum: Object.values(STORAGE_UPLOAD_KIND),
|
|
31
|
+
},
|
|
32
|
+
ref_type: {
|
|
33
|
+
type: String,
|
|
34
|
+
required: true,
|
|
35
|
+
enum: ALL_PENDING_UPLOAD_REF_TYPES,
|
|
36
|
+
},
|
|
37
|
+
ref_id: {
|
|
38
|
+
type: String,
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
stage: {
|
|
42
|
+
type: String,
|
|
43
|
+
enum: ALL_PENDING_UPLOAD_STAGES,
|
|
44
|
+
},
|
|
45
|
+
mime: { type: String, required: true },
|
|
46
|
+
max_bytes: { type: Number, required: true },
|
|
47
|
+
uploaded_at: { type: Date, default: null },
|
|
48
|
+
committed_at: { type: Date, default: null },
|
|
49
|
+
discarded_at: { type: Date, default: null },
|
|
50
|
+
expires_at: { type: Date, required: true },
|
|
51
|
+
size: { type: Number, default: null },
|
|
52
|
+
content_type: { type: String, default: null },
|
|
53
|
+
generation: { type: String, default: null },
|
|
54
|
+
createdAt: {
|
|
55
|
+
type: Date,
|
|
56
|
+
required: true,
|
|
57
|
+
immutable: true,
|
|
58
|
+
default: () => new Date(),
|
|
59
|
+
},
|
|
60
|
+
updatedAt: {
|
|
61
|
+
type: Date,
|
|
62
|
+
required: true,
|
|
63
|
+
default: () => new Date(),
|
|
64
|
+
},
|
|
65
|
+
}, {
|
|
66
|
+
collection: PENDING_UPLOADS_COLLECTION_NAME,
|
|
67
|
+
timestamps: true,
|
|
68
|
+
versionKey: false,
|
|
69
|
+
minimize: false,
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* Describes the indexes for `pending_uploads`. Values are Mongo key patterns
|
|
73
|
+
* that can be passed to `.hint()`; creation must use
|
|
74
|
+
* `PENDING_UPLOADS_INDEX_OPTIONS`.
|
|
75
|
+
*/
|
|
76
|
+
export const PENDING_UPLOADS_COLLECTION_INDEXES = {
|
|
77
|
+
_id: { _id: 1 }, // Unique Index
|
|
78
|
+
path: { path: 1 }, // unique server-built upload path
|
|
79
|
+
uid__createdAt: { uid: 1, createdAt: -1 }, // per-user upload history
|
|
80
|
+
expires_at: { expires_at: 1 }, // TTL audit cleanup
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Index OPTIONS the owner must CREATE. This is declared in the toolkit and
|
|
84
|
+
* applied by a separate migration/deploy step; it is never created by a read
|
|
85
|
+
* at runtime (services connect with `autoIndex: false`).
|
|
86
|
+
*/
|
|
87
|
+
export const PENDING_UPLOADS_INDEX_OPTIONS = [
|
|
88
|
+
{
|
|
89
|
+
key: { path: 1 },
|
|
90
|
+
name: 'path',
|
|
91
|
+
unique: true,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
key: { uid: 1, createdAt: -1 },
|
|
95
|
+
name: 'uid__createdAt',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
key: { expires_at: 1 },
|
|
99
|
+
name: 'expires_at_ttl',
|
|
100
|
+
expireAfterSeconds: 0,
|
|
101
|
+
},
|
|
102
|
+
];
|
|
@@ -66,6 +66,7 @@ export * from './offers';
|
|
|
66
66
|
export * from './offers_fingerprints';
|
|
67
67
|
export * from './operational_roles';
|
|
68
68
|
export * from './orders';
|
|
69
|
+
export * from './pending_uploads';
|
|
69
70
|
export * from './printer_settings';
|
|
70
71
|
export * from './public_holidays';
|
|
71
72
|
export * from './reservations';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/constants/ENUMS.d.ts
CHANGED
package/lib/constants/ENUMS.js
CHANGED
|
@@ -31,5 +31,6 @@ __exportStar(require("./enums/order"), exports);
|
|
|
31
31
|
__exportStar(require("./enums/payments"), exports);
|
|
32
32
|
__exportStar(require("./enums/platform"), exports);
|
|
33
33
|
__exportStar(require("./enums/printing"), exports);
|
|
34
|
+
__exportStar(require("./enums/storage"), exports);
|
|
34
35
|
__exportStar(require("./enums/users"), exports);
|
|
35
36
|
__exportStar(require("./enums/wallet"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare enum PENDING_UPLOAD_REF_TYPE_ENUM {
|
|
2
|
+
TENANT = "TENANT",
|
|
3
|
+
BRAND = "BRAND",
|
|
4
|
+
WAREHOUSE = "WAREHOUSE",
|
|
5
|
+
EMPLOYEE = "EMPLOYEE",
|
|
6
|
+
DELIVERY = "DELIVERY",
|
|
7
|
+
RIDER = "RIDER",
|
|
8
|
+
RESTAURANT = "RESTAURANT",
|
|
9
|
+
EXPENSE = "EXPENSE"
|
|
10
|
+
}
|
|
11
|
+
export declare const ALL_PENDING_UPLOAD_REF_TYPES: PENDING_UPLOAD_REF_TYPE_ENUM[];
|
|
12
|
+
/**
|
|
13
|
+
* Delivery proof stage. Enum values are upper-case by enum convention;
|
|
14
|
+
* the path builder lower-cases them into the storage leaf
|
|
15
|
+
* (`pickup_food_image_url.<ext>` / `dropoff_food_image_url.<ext>`).
|
|
16
|
+
*/
|
|
17
|
+
export declare enum PENDING_UPLOAD_STAGE_ENUM {
|
|
18
|
+
PICKUP = "PICKUP",
|
|
19
|
+
DROPOFF = "DROPOFF"
|
|
20
|
+
}
|
|
21
|
+
export declare const ALL_PENDING_UPLOAD_STAGES: PENDING_UPLOAD_STAGE_ENUM[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALL_PENDING_UPLOAD_STAGES = exports.PENDING_UPLOAD_STAGE_ENUM = exports.ALL_PENDING_UPLOAD_REF_TYPES = exports.PENDING_UPLOAD_REF_TYPE_ENUM = void 0;
|
|
4
|
+
var PENDING_UPLOAD_REF_TYPE_ENUM;
|
|
5
|
+
(function (PENDING_UPLOAD_REF_TYPE_ENUM) {
|
|
6
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["TENANT"] = "TENANT";
|
|
7
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["BRAND"] = "BRAND";
|
|
8
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["WAREHOUSE"] = "WAREHOUSE";
|
|
9
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["EMPLOYEE"] = "EMPLOYEE";
|
|
10
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["DELIVERY"] = "DELIVERY";
|
|
11
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["RIDER"] = "RIDER";
|
|
12
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["RESTAURANT"] = "RESTAURANT";
|
|
13
|
+
PENDING_UPLOAD_REF_TYPE_ENUM["EXPENSE"] = "EXPENSE";
|
|
14
|
+
})(PENDING_UPLOAD_REF_TYPE_ENUM || (exports.PENDING_UPLOAD_REF_TYPE_ENUM = PENDING_UPLOAD_REF_TYPE_ENUM = {}));
|
|
15
|
+
exports.ALL_PENDING_UPLOAD_REF_TYPES = Object.values(PENDING_UPLOAD_REF_TYPE_ENUM);
|
|
16
|
+
/**
|
|
17
|
+
* Delivery proof stage. Enum values are upper-case by enum convention;
|
|
18
|
+
* the path builder lower-cases them into the storage leaf
|
|
19
|
+
* (`pickup_food_image_url.<ext>` / `dropoff_food_image_url.<ext>`).
|
|
20
|
+
*/
|
|
21
|
+
var PENDING_UPLOAD_STAGE_ENUM;
|
|
22
|
+
(function (PENDING_UPLOAD_STAGE_ENUM) {
|
|
23
|
+
PENDING_UPLOAD_STAGE_ENUM["PICKUP"] = "PICKUP";
|
|
24
|
+
PENDING_UPLOAD_STAGE_ENUM["DROPOFF"] = "DROPOFF";
|
|
25
|
+
})(PENDING_UPLOAD_STAGE_ENUM || (exports.PENDING_UPLOAD_STAGE_ENUM = PENDING_UPLOAD_STAGE_ENUM = {}));
|
|
26
|
+
exports.ALL_PENDING_UPLOAD_STAGES = Object.values(PENDING_UPLOAD_STAGE_ENUM);
|
package/lib/helpers/index.d.ts
CHANGED
package/lib/helpers/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __exportStar(require("./rider-reports"), exports);
|
|
|
24
24
|
__exportStar(require("./order"), exports);
|
|
25
25
|
__exportStar(require("./pra"), exports);
|
|
26
26
|
__exportStar(require("./srb"), exports);
|
|
27
|
+
__exportStar(require("./storage"), exports);
|
|
27
28
|
__exportStar(require("./store"), exports);
|
|
28
29
|
__exportStar(require("./types"), exports);
|
|
29
30
|
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './upload-paths';
|