@nfcard/validation 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +61 -1
- package/dist/index.js +0 -0
- package/package.json +1 -1
- package/src/index.test.ts +72 -0
- package/src/index.ts +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -5300,6 +5300,28 @@ declare const digitalConfigSchema: z.ZodObject<{
|
|
|
5300
5300
|
label?: string | undefined;
|
|
5301
5301
|
}[] | undefined;
|
|
5302
5302
|
}>;
|
|
5303
|
+
declare const entrySourceSchema: z.ZodObject<{
|
|
5304
|
+
output: z.ZodOptional<z.ZodEnum<["with-card", "digital-only"]>>;
|
|
5305
|
+
entryFlow: z.ZodOptional<z.ZodEnum<["order", "try"]>>;
|
|
5306
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
5307
|
+
path: z.ZodOptional<z.ZodString>;
|
|
5308
|
+
referrer: z.ZodOptional<z.ZodString>;
|
|
5309
|
+
utm: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodString>, Record<string, string>, Record<string, string>>>;
|
|
5310
|
+
}, "strict", z.ZodTypeAny, {
|
|
5311
|
+
path?: string | undefined;
|
|
5312
|
+
output?: "with-card" | "digital-only" | undefined;
|
|
5313
|
+
entryFlow?: "order" | "try" | undefined;
|
|
5314
|
+
ref?: string | undefined;
|
|
5315
|
+
referrer?: string | undefined;
|
|
5316
|
+
utm?: Record<string, string> | undefined;
|
|
5317
|
+
}, {
|
|
5318
|
+
path?: string | undefined;
|
|
5319
|
+
output?: "with-card" | "digital-only" | undefined;
|
|
5320
|
+
entryFlow?: "order" | "try" | undefined;
|
|
5321
|
+
ref?: string | undefined;
|
|
5322
|
+
referrer?: string | undefined;
|
|
5323
|
+
utm?: Record<string, string> | undefined;
|
|
5324
|
+
}>;
|
|
5303
5325
|
declare const configurationCreateSchema: z.ZodObject<{
|
|
5304
5326
|
sessionId: z.ZodString;
|
|
5305
5327
|
userData: z.ZodObject<{
|
|
@@ -8838,6 +8860,28 @@ declare const configurationCreateSchema: z.ZodObject<{
|
|
|
8838
8860
|
quantity: z.ZodDefault<z.ZodNumber>;
|
|
8839
8861
|
existingProfileId: z.ZodOptional<z.ZodString>;
|
|
8840
8862
|
physicalTemplateId: z.ZodOptional<z.ZodString>;
|
|
8863
|
+
entrySource: z.ZodOptional<z.ZodObject<{
|
|
8864
|
+
output: z.ZodOptional<z.ZodEnum<["with-card", "digital-only"]>>;
|
|
8865
|
+
entryFlow: z.ZodOptional<z.ZodEnum<["order", "try"]>>;
|
|
8866
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
8867
|
+
path: z.ZodOptional<z.ZodString>;
|
|
8868
|
+
referrer: z.ZodOptional<z.ZodString>;
|
|
8869
|
+
utm: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodString>, Record<string, string>, Record<string, string>>>;
|
|
8870
|
+
}, "strict", z.ZodTypeAny, {
|
|
8871
|
+
path?: string | undefined;
|
|
8872
|
+
output?: "with-card" | "digital-only" | undefined;
|
|
8873
|
+
entryFlow?: "order" | "try" | undefined;
|
|
8874
|
+
ref?: string | undefined;
|
|
8875
|
+
referrer?: string | undefined;
|
|
8876
|
+
utm?: Record<string, string> | undefined;
|
|
8877
|
+
}, {
|
|
8878
|
+
path?: string | undefined;
|
|
8879
|
+
output?: "with-card" | "digital-only" | undefined;
|
|
8880
|
+
entryFlow?: "order" | "try" | undefined;
|
|
8881
|
+
ref?: string | undefined;
|
|
8882
|
+
referrer?: string | undefined;
|
|
8883
|
+
utm?: Record<string, string> | undefined;
|
|
8884
|
+
}>>;
|
|
8841
8885
|
}, "strip", z.ZodTypeAny, {
|
|
8842
8886
|
sessionId: string;
|
|
8843
8887
|
userData: {
|
|
@@ -9194,6 +9238,14 @@ declare const configurationCreateSchema: z.ZodObject<{
|
|
|
9194
9238
|
quantity: number;
|
|
9195
9239
|
existingProfileId?: string | undefined;
|
|
9196
9240
|
physicalTemplateId?: string | undefined;
|
|
9241
|
+
entrySource?: {
|
|
9242
|
+
path?: string | undefined;
|
|
9243
|
+
output?: "with-card" | "digital-only" | undefined;
|
|
9244
|
+
entryFlow?: "order" | "try" | undefined;
|
|
9245
|
+
ref?: string | undefined;
|
|
9246
|
+
referrer?: string | undefined;
|
|
9247
|
+
utm?: Record<string, string> | undefined;
|
|
9248
|
+
} | undefined;
|
|
9197
9249
|
}, {
|
|
9198
9250
|
sessionId: string;
|
|
9199
9251
|
userData: {
|
|
@@ -9550,6 +9602,14 @@ declare const configurationCreateSchema: z.ZodObject<{
|
|
|
9550
9602
|
quantity?: number | undefined;
|
|
9551
9603
|
existingProfileId?: string | undefined;
|
|
9552
9604
|
physicalTemplateId?: string | undefined;
|
|
9605
|
+
entrySource?: {
|
|
9606
|
+
path?: string | undefined;
|
|
9607
|
+
output?: "with-card" | "digital-only" | undefined;
|
|
9608
|
+
entryFlow?: "order" | "try" | undefined;
|
|
9609
|
+
ref?: string | undefined;
|
|
9610
|
+
referrer?: string | undefined;
|
|
9611
|
+
utm?: Record<string, string> | undefined;
|
|
9612
|
+
} | undefined;
|
|
9553
9613
|
}>;
|
|
9554
9614
|
declare const configurationUpdateSchema: z.ZodObject<{
|
|
9555
9615
|
userData: z.ZodOptional<z.ZodObject<{
|
|
@@ -19709,4 +19769,4 @@ declare function validatePhysicalConfig(data: unknown): ValidationResult<z.infer
|
|
|
19709
19769
|
declare function validateDigitalConfig(data: unknown): ValidationResult<z.infer<typeof digitalConfigSchema>>;
|
|
19710
19770
|
declare function validateConfiguration(data: unknown): ValidationResult<z.infer<typeof configurationCreateSchema>>;
|
|
19711
19771
|
|
|
19712
|
-
export { CARD_H_MM, CARD_W_MM, CHIP_RADIUS_MM, CHIP_SCALE_FLOOR, type ChipAxis, EDGE_MARGIN_MM, MAX_CTA_BUTTONS, MIN_WALL_MM, NFC_COIL_DIAMETER_MM, NFC_RADIAL_CLEARANCE_MM, type PrintabilityCtx, type Pt, QR_MATRIX_CELLS, QR_MIN_SIZE_MM, QR_MODULE_MIN_MM, TEXT_MIN_EM_MM, type ValidationResult, type Violation, adminCardCreateSchema, cardAssetSchema, cardDesignMaterialSchema, cardDesignPatternSchema, cardDesignSchema, cardElementSchema, cardElementsSchema, cardProfileUpdateSchema, cardUpdateSchema, chipAnchorToMm, comboIdSchema, configurationCreateSchema, configurationUpdateSchema, contactDetailTogglesSchema, contactExchangeSchema, cornersOnCard, createOrderSchema, ctaButtonSchema, ctaButtonsSchema, digitalConfigSchema, digitalVisibilitySchema, elementPrintability, elementTransformSchema, hubConfigSchema, hubProfilesUpdateSchema, isFiniteTransform, materialSchema, mmToNearestChipAnchor, obbCorners, patternFamilySchema, physicalConfigSchema, physicalContentOverridesSchema, profileAccessTokenCreateSchema, profileCreateSchema, profilePinVerifySchema, profileUpdateSchema, profileUserDataSchema, profileVisibilitySchema, sanitizeHttpUrl, sanitizeText, signupWithProfileSchema, socialLinksSchema, socialOverridesSchema, userDataSchema, validateConfiguration, validateDigitalConfig, validatePhysicalConfig, validateUserData, webAddressSchema };
|
|
19772
|
+
export { CARD_H_MM, CARD_W_MM, CHIP_RADIUS_MM, CHIP_SCALE_FLOOR, type ChipAxis, EDGE_MARGIN_MM, MAX_CTA_BUTTONS, MIN_WALL_MM, NFC_COIL_DIAMETER_MM, NFC_RADIAL_CLEARANCE_MM, type PrintabilityCtx, type Pt, QR_MATRIX_CELLS, QR_MIN_SIZE_MM, QR_MODULE_MIN_MM, TEXT_MIN_EM_MM, type ValidationResult, type Violation, adminCardCreateSchema, cardAssetSchema, cardDesignMaterialSchema, cardDesignPatternSchema, cardDesignSchema, cardElementSchema, cardElementsSchema, cardProfileUpdateSchema, cardUpdateSchema, chipAnchorToMm, comboIdSchema, configurationCreateSchema, configurationUpdateSchema, contactDetailTogglesSchema, contactExchangeSchema, cornersOnCard, createOrderSchema, ctaButtonSchema, ctaButtonsSchema, digitalConfigSchema, digitalVisibilitySchema, elementPrintability, elementTransformSchema, entrySourceSchema, hubConfigSchema, hubProfilesUpdateSchema, isFiniteTransform, materialSchema, mmToNearestChipAnchor, obbCorners, patternFamilySchema, physicalConfigSchema, physicalContentOverridesSchema, profileAccessTokenCreateSchema, profileCreateSchema, profilePinVerifySchema, profileUpdateSchema, profileUserDataSchema, profileVisibilitySchema, sanitizeHttpUrl, sanitizeText, signupWithProfileSchema, socialLinksSchema, socialOverridesSchema, userDataSchema, validateConfiguration, validateDigitalConfig, validatePhysicalConfig, validateUserData, webAddressSchema };
|
package/dist/index.js
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/index.test.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
cardElementsSchema,
|
|
5
5
|
comboIdSchema,
|
|
6
6
|
configurationCreateSchema,
|
|
7
|
+
configurationUpdateSchema,
|
|
7
8
|
contactExchangeSchema,
|
|
8
9
|
createOrderSchema,
|
|
9
10
|
ctaButtonsSchema,
|
|
@@ -973,3 +974,74 @@ describe('physicalConfig.cardDesign (nested, not stripped)', () => {
|
|
|
973
974
|
expect(physicalConfigSchema.safeParse(validPhysicalConfig).success).toBe(true);
|
|
974
975
|
});
|
|
975
976
|
});
|
|
977
|
+
|
|
978
|
+
// -- entrySourceSchema (NFCARD-392) --------------------------------
|
|
979
|
+
|
|
980
|
+
describe('entrySourceSchema on configurationCreateSchema', () => {
|
|
981
|
+
const base = {
|
|
982
|
+
sessionId: '550e8400-e29b-41d4-a716-446655440000',
|
|
983
|
+
userData: validUserData,
|
|
984
|
+
physicalConfig: validPhysicalConfig,
|
|
985
|
+
digitalConfig: validDigitalConfig,
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
it('accepts a full entry-attribution blob', () => {
|
|
989
|
+
const r = configurationCreateSchema.safeParse({
|
|
990
|
+
...base,
|
|
991
|
+
entrySource: {
|
|
992
|
+
output: 'with-card',
|
|
993
|
+
entryFlow: 'order',
|
|
994
|
+
ref: 'PROMO24',
|
|
995
|
+
path: '/configurator',
|
|
996
|
+
referrer: 'google.com',
|
|
997
|
+
utm: { utm_source: 'ads', utm_campaign: 'launch' },
|
|
998
|
+
},
|
|
999
|
+
});
|
|
1000
|
+
expect(r.success).toBe(true);
|
|
1001
|
+
if (r.success) expect(r.data.entrySource?.output).toBe('with-card');
|
|
1002
|
+
});
|
|
1003
|
+
|
|
1004
|
+
it('is optional — older clients omit it entirely', () => {
|
|
1005
|
+
const r = configurationCreateSchema.safeParse(base);
|
|
1006
|
+
expect(r.success).toBe(true);
|
|
1007
|
+
if (r.success) expect(r.data.entrySource).toBeUndefined();
|
|
1008
|
+
});
|
|
1009
|
+
|
|
1010
|
+
it('rejects unknown keys (strict) and out-of-enum values', () => {
|
|
1011
|
+
expect(
|
|
1012
|
+
configurationCreateSchema.safeParse({
|
|
1013
|
+
...base,
|
|
1014
|
+
entrySource: { output: 'with-card', evil: 'payload' },
|
|
1015
|
+
}).success,
|
|
1016
|
+
).toBe(false);
|
|
1017
|
+
expect(
|
|
1018
|
+
configurationCreateSchema.safeParse({
|
|
1019
|
+
...base,
|
|
1020
|
+
entrySource: { output: 'both-please' },
|
|
1021
|
+
}).success,
|
|
1022
|
+
).toBe(false);
|
|
1023
|
+
});
|
|
1024
|
+
|
|
1025
|
+
it('bounds the utm map (max 10 entries, capped value length)', () => {
|
|
1026
|
+
const utm: Record<string, string> = {};
|
|
1027
|
+
for (let i = 0; i < 11; i++) utm['k' + i] = 'v';
|
|
1028
|
+
expect(
|
|
1029
|
+
configurationCreateSchema.safeParse({ ...base, entrySource: { utm } }).success,
|
|
1030
|
+
).toBe(false);
|
|
1031
|
+
expect(
|
|
1032
|
+
configurationCreateSchema.safeParse({
|
|
1033
|
+
...base,
|
|
1034
|
+
entrySource: { referrer: 'x'.repeat(300) },
|
|
1035
|
+
}).success,
|
|
1036
|
+
).toBe(false);
|
|
1037
|
+
});
|
|
1038
|
+
|
|
1039
|
+
it('is create-only: the update schema strips/ignores it', () => {
|
|
1040
|
+
const r = configurationUpdateSchema.safeParse({
|
|
1041
|
+
entrySource: { output: 'with-card' },
|
|
1042
|
+
});
|
|
1043
|
+
// z.object strips unknown keys by default - the field must not survive.
|
|
1044
|
+
expect(r.success).toBe(true);
|
|
1045
|
+
if (r.success) expect((r.data as Record<string, unknown>).entrySource).toBeUndefined();
|
|
1046
|
+
});
|
|
1047
|
+
});
|
package/src/index.ts
CHANGED
|
Binary file
|