@joeygrable94/utm-src-pub-validators 0.0.24 → 0.0.25
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.cjs +8 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -10
- package/dist/index.d.ts +33 -10
- package/dist/index.js +8 -11
- package/dist/index.js.map +1 -1
- package/package.json +9 -2
package/dist/index.d.cts
CHANGED
|
@@ -52,12 +52,35 @@ declare const ERROR_MESSAGE_REGEX_VALUE = "can only contain letters, numbers, an
|
|
|
52
52
|
declare const REGEX_DOMAIN: RegExp;
|
|
53
53
|
declare const ERROR_MESSAGE_REGEX_DOMAIN = "please provide a valid domain name";
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Example usage of GroupEntityScope type
|
|
57
|
+
* @reference https://youtube.com/shorts/zOseJFD447U?si=xX8DYEHdl9YtN7S4
|
|
58
|
+
*
|
|
59
|
+
* > const validScope: GroupEntityScope = "tracking-link:import"; // ✅
|
|
60
|
+
* > const invalidScope: GroupEntityScope = "website:import"; // ❌ Type error!
|
|
61
|
+
*/
|
|
62
|
+
declare const GROUP_ENTITY_PERMISSIONS: {
|
|
63
|
+
readonly website: readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
64
|
+
readonly "tracking-link": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
65
|
+
readonly source: readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
66
|
+
readonly medium: readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
67
|
+
readonly "campaign-id": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
68
|
+
readonly "campaign-phase": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
69
|
+
readonly "campaign-product": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
70
|
+
readonly "campaign-key": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
71
|
+
readonly content: readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
72
|
+
readonly "creative-format": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
73
|
+
readonly "creative-format-variant": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
74
|
+
readonly term: readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
75
|
+
};
|
|
76
|
+
type GroupEntityKey = keyof typeof GROUP_ENTITY_PERMISSIONS;
|
|
77
|
+
type GroupEntityActions<K extends GroupEntityKey = GroupEntityKey> = (typeof GROUP_ENTITY_PERMISSIONS)[K][number];
|
|
78
|
+
type EntityActionJoin<K extends string, V extends string> = `${K}:${V}`;
|
|
79
|
+
type GroupEntityScope = {
|
|
80
|
+
[K in GroupEntityKey]: EntityActionJoin<K, (typeof GROUP_ENTITY_PERMISSIONS)[K][number]>;
|
|
81
|
+
}[GroupEntityKey];
|
|
59
82
|
declare const GROUP_ENTITY_KEYS: GroupEntityKey[];
|
|
60
|
-
declare const GROUP_ENTITY_SCOPES:
|
|
83
|
+
declare const GROUP_ENTITY_SCOPES: GroupEntityScope[];
|
|
61
84
|
|
|
62
85
|
type ValidateAndCleanSuccess<T> = {
|
|
63
86
|
data: Partial<T>;
|
|
@@ -100,7 +123,7 @@ declare const IsValidOrUndefinedApplyValueTo: v.UndefinedableSchema<v.PicklistSc
|
|
|
100
123
|
declare const IsValidApplyValueAs: v.PicklistSchema<["prefix", "suffix"], undefined>;
|
|
101
124
|
declare const IsValidOrUndefinedApplyValueAs: v.UndefinedableSchema<v.PicklistSchema<["prefix", "suffix"], undefined>, undefined>;
|
|
102
125
|
|
|
103
|
-
declare const IsValidGroupUserScopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<
|
|
126
|
+
declare const IsValidGroupUserScopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<GroupEntityScope[], "invalid group scope provided">]>, "please provide an array of scopes">, v.MinLengthAction<GroupEntityScope[], 1, "you must provide at least one scope">, v.MaxLengthAction<GroupEntityScope[], number, "you cannot provide more scopes than available">]>;
|
|
104
127
|
|
|
105
128
|
declare const IsValidProductId: v.SchemaWithPipe<readonly [v.StringSchema<"please provide a product_id">, v.TrimAction, v.MinLengthAction<string, 2, "the product_id is too short, it must be at least 2 characters">, v.MaxLengthAction<string, 64, "the product_id is too long, it must be 64 characters or less">]>;
|
|
106
129
|
declare const IsValidOrUndefinedProductId: v.UndefinedableSchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a product_id">, v.TrimAction, v.MinLengthAction<string, 2, "the product_id is too short, it must be at least 2 characters">, v.MaxLengthAction<string, 64, "the product_id is too long, it must be 64 characters or less">]>, undefined>;
|
|
@@ -606,7 +629,7 @@ type SDeleteCreativeFormatDocument = v.InferOutput<typeof SDeleteCreativeFormatD
|
|
|
606
629
|
declare const SCreateGroupUserDocument: v.ObjectSchema<{
|
|
607
630
|
readonly group: v.StringSchema<"please provide a valid document id">;
|
|
608
631
|
readonly user: v.StringSchema<"please provide a valid document id">;
|
|
609
|
-
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<
|
|
632
|
+
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<GroupEntityScope[], "invalid group scope provided">]>, "please provide an array of scopes">, v.MinLengthAction<GroupEntityScope[], 1, "you must provide at least one scope">, v.MaxLengthAction<GroupEntityScope[], number, "you cannot provide more scopes than available">]>;
|
|
610
633
|
}, undefined>;
|
|
611
634
|
type SCreateGroupUserDocument = v.InferOutput<typeof SCreateGroupUserDocument>;
|
|
612
635
|
declare const SCreateGroupUserDocumentRequest: v.ObjectSchema<{
|
|
@@ -614,7 +637,7 @@ declare const SCreateGroupUserDocumentRequest: v.ObjectSchema<{
|
|
|
614
637
|
readonly data: v.ObjectSchema<{
|
|
615
638
|
readonly group: v.StringSchema<"please provide a valid document id">;
|
|
616
639
|
readonly user: v.StringSchema<"please provide a valid document id">;
|
|
617
|
-
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<
|
|
640
|
+
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<GroupEntityScope[], "invalid group scope provided">]>, "please provide an array of scopes">, v.MinLengthAction<GroupEntityScope[], 1, "you must provide at least one scope">, v.MaxLengthAction<GroupEntityScope[], number, "you cannot provide more scopes than available">]>;
|
|
618
641
|
}, undefined>;
|
|
619
642
|
}, undefined>;
|
|
620
643
|
type SCreateGroupUserDocumentRequest = v.InferOutput<typeof SCreateGroupUserDocumentRequest>;
|
|
@@ -627,13 +650,13 @@ declare const SReadGroupUserDocumentByDocumentId: v.ObjectSchema<{
|
|
|
627
650
|
}, undefined>;
|
|
628
651
|
type SReadGroupUserDocumentByDocumentId = v.InferOutput<typeof SReadGroupUserDocumentByDocumentId>;
|
|
629
652
|
declare const SUpdateGroupUserDocument: v.ObjectSchema<{
|
|
630
|
-
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<
|
|
653
|
+
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<GroupEntityScope[], "invalid group scope provided">]>, "please provide an array of scopes">, v.MinLengthAction<GroupEntityScope[], 1, "you must provide at least one scope">, v.MaxLengthAction<GroupEntityScope[], number, "you cannot provide more scopes than available">]>;
|
|
631
654
|
}, undefined>;
|
|
632
655
|
type SUpdateGroupUserDocument = v.InferOutput<typeof SUpdateGroupUserDocument>;
|
|
633
656
|
declare const SUpdateGroupUserDocumentRequest: v.ObjectSchema<{
|
|
634
657
|
readonly documentId: v.StringSchema<"please provide a valid document id">;
|
|
635
658
|
readonly data: v.ObjectSchema<{
|
|
636
|
-
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<
|
|
659
|
+
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<GroupEntityScope[], "invalid group scope provided">]>, "please provide an array of scopes">, v.MinLengthAction<GroupEntityScope[], 1, "you must provide at least one scope">, v.MaxLengthAction<GroupEntityScope[], number, "you cannot provide more scopes than available">]>;
|
|
637
660
|
}, undefined>;
|
|
638
661
|
}, undefined>;
|
|
639
662
|
type SUpdateGroupUserDocumentRequest = v.InferOutput<typeof SUpdateGroupUserDocumentRequest>;
|
package/dist/index.d.ts
CHANGED
|
@@ -52,12 +52,35 @@ declare const ERROR_MESSAGE_REGEX_VALUE = "can only contain letters, numbers, an
|
|
|
52
52
|
declare const REGEX_DOMAIN: RegExp;
|
|
53
53
|
declare const ERROR_MESSAGE_REGEX_DOMAIN = "please provide a valid domain name";
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Example usage of GroupEntityScope type
|
|
57
|
+
* @reference https://youtube.com/shorts/zOseJFD447U?si=xX8DYEHdl9YtN7S4
|
|
58
|
+
*
|
|
59
|
+
* > const validScope: GroupEntityScope = "tracking-link:import"; // ✅
|
|
60
|
+
* > const invalidScope: GroupEntityScope = "website:import"; // ❌ Type error!
|
|
61
|
+
*/
|
|
62
|
+
declare const GROUP_ENTITY_PERMISSIONS: {
|
|
63
|
+
readonly website: readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
64
|
+
readonly "tracking-link": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
65
|
+
readonly source: readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
66
|
+
readonly medium: readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
67
|
+
readonly "campaign-id": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
68
|
+
readonly "campaign-phase": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
69
|
+
readonly "campaign-product": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
70
|
+
readonly "campaign-key": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
71
|
+
readonly content: readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
72
|
+
readonly "creative-format": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
73
|
+
readonly "creative-format-variant": readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
74
|
+
readonly term: readonly ["list", "create", "read", "update", "delete", "export", "import"];
|
|
75
|
+
};
|
|
76
|
+
type GroupEntityKey = keyof typeof GROUP_ENTITY_PERMISSIONS;
|
|
77
|
+
type GroupEntityActions<K extends GroupEntityKey = GroupEntityKey> = (typeof GROUP_ENTITY_PERMISSIONS)[K][number];
|
|
78
|
+
type EntityActionJoin<K extends string, V extends string> = `${K}:${V}`;
|
|
79
|
+
type GroupEntityScope = {
|
|
80
|
+
[K in GroupEntityKey]: EntityActionJoin<K, (typeof GROUP_ENTITY_PERMISSIONS)[K][number]>;
|
|
81
|
+
}[GroupEntityKey];
|
|
59
82
|
declare const GROUP_ENTITY_KEYS: GroupEntityKey[];
|
|
60
|
-
declare const GROUP_ENTITY_SCOPES:
|
|
83
|
+
declare const GROUP_ENTITY_SCOPES: GroupEntityScope[];
|
|
61
84
|
|
|
62
85
|
type ValidateAndCleanSuccess<T> = {
|
|
63
86
|
data: Partial<T>;
|
|
@@ -100,7 +123,7 @@ declare const IsValidOrUndefinedApplyValueTo: v.UndefinedableSchema<v.PicklistSc
|
|
|
100
123
|
declare const IsValidApplyValueAs: v.PicklistSchema<["prefix", "suffix"], undefined>;
|
|
101
124
|
declare const IsValidOrUndefinedApplyValueAs: v.UndefinedableSchema<v.PicklistSchema<["prefix", "suffix"], undefined>, undefined>;
|
|
102
125
|
|
|
103
|
-
declare const IsValidGroupUserScopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<
|
|
126
|
+
declare const IsValidGroupUserScopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<GroupEntityScope[], "invalid group scope provided">]>, "please provide an array of scopes">, v.MinLengthAction<GroupEntityScope[], 1, "you must provide at least one scope">, v.MaxLengthAction<GroupEntityScope[], number, "you cannot provide more scopes than available">]>;
|
|
104
127
|
|
|
105
128
|
declare const IsValidProductId: v.SchemaWithPipe<readonly [v.StringSchema<"please provide a product_id">, v.TrimAction, v.MinLengthAction<string, 2, "the product_id is too short, it must be at least 2 characters">, v.MaxLengthAction<string, 64, "the product_id is too long, it must be 64 characters or less">]>;
|
|
106
129
|
declare const IsValidOrUndefinedProductId: v.UndefinedableSchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a product_id">, v.TrimAction, v.MinLengthAction<string, 2, "the product_id is too short, it must be at least 2 characters">, v.MaxLengthAction<string, 64, "the product_id is too long, it must be 64 characters or less">]>, undefined>;
|
|
@@ -606,7 +629,7 @@ type SDeleteCreativeFormatDocument = v.InferOutput<typeof SDeleteCreativeFormatD
|
|
|
606
629
|
declare const SCreateGroupUserDocument: v.ObjectSchema<{
|
|
607
630
|
readonly group: v.StringSchema<"please provide a valid document id">;
|
|
608
631
|
readonly user: v.StringSchema<"please provide a valid document id">;
|
|
609
|
-
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<
|
|
632
|
+
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<GroupEntityScope[], "invalid group scope provided">]>, "please provide an array of scopes">, v.MinLengthAction<GroupEntityScope[], 1, "you must provide at least one scope">, v.MaxLengthAction<GroupEntityScope[], number, "you cannot provide more scopes than available">]>;
|
|
610
633
|
}, undefined>;
|
|
611
634
|
type SCreateGroupUserDocument = v.InferOutput<typeof SCreateGroupUserDocument>;
|
|
612
635
|
declare const SCreateGroupUserDocumentRequest: v.ObjectSchema<{
|
|
@@ -614,7 +637,7 @@ declare const SCreateGroupUserDocumentRequest: v.ObjectSchema<{
|
|
|
614
637
|
readonly data: v.ObjectSchema<{
|
|
615
638
|
readonly group: v.StringSchema<"please provide a valid document id">;
|
|
616
639
|
readonly user: v.StringSchema<"please provide a valid document id">;
|
|
617
|
-
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<
|
|
640
|
+
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<GroupEntityScope[], "invalid group scope provided">]>, "please provide an array of scopes">, v.MinLengthAction<GroupEntityScope[], 1, "you must provide at least one scope">, v.MaxLengthAction<GroupEntityScope[], number, "you cannot provide more scopes than available">]>;
|
|
618
641
|
}, undefined>;
|
|
619
642
|
}, undefined>;
|
|
620
643
|
type SCreateGroupUserDocumentRequest = v.InferOutput<typeof SCreateGroupUserDocumentRequest>;
|
|
@@ -627,13 +650,13 @@ declare const SReadGroupUserDocumentByDocumentId: v.ObjectSchema<{
|
|
|
627
650
|
}, undefined>;
|
|
628
651
|
type SReadGroupUserDocumentByDocumentId = v.InferOutput<typeof SReadGroupUserDocumentByDocumentId>;
|
|
629
652
|
declare const SUpdateGroupUserDocument: v.ObjectSchema<{
|
|
630
|
-
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<
|
|
653
|
+
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<GroupEntityScope[], "invalid group scope provided">]>, "please provide an array of scopes">, v.MinLengthAction<GroupEntityScope[], 1, "you must provide at least one scope">, v.MaxLengthAction<GroupEntityScope[], number, "you cannot provide more scopes than available">]>;
|
|
631
654
|
}, undefined>;
|
|
632
655
|
type SUpdateGroupUserDocument = v.InferOutput<typeof SUpdateGroupUserDocument>;
|
|
633
656
|
declare const SUpdateGroupUserDocumentRequest: v.ObjectSchema<{
|
|
634
657
|
readonly documentId: v.StringSchema<"please provide a valid document id">;
|
|
635
658
|
readonly data: v.ObjectSchema<{
|
|
636
|
-
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<
|
|
659
|
+
readonly scopes: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<"please provide a valid scope">, v.PicklistSchema<GroupEntityScope[], "invalid group scope provided">]>, "please provide an array of scopes">, v.MinLengthAction<GroupEntityScope[], 1, "you must provide at least one scope">, v.MaxLengthAction<GroupEntityScope[], number, "you cannot provide more scopes than available">]>;
|
|
637
660
|
}, undefined>;
|
|
638
661
|
}, undefined>;
|
|
639
662
|
type SUpdateGroupUserDocumentRequest = v.InferOutput<typeof SUpdateGroupUserDocumentRequest>;
|
package/dist/index.js
CHANGED
|
@@ -56,26 +56,23 @@ var ERROR_MESSAGE_REGEX_DOMAIN = "please provide a valid domain name";
|
|
|
56
56
|
|
|
57
57
|
// src/constants/constants-permissions.ts
|
|
58
58
|
var GROUP_ENTITY_PERMISSIONS = {
|
|
59
|
-
|
|
59
|
+
website: ["list", "create", "read", "update", "delete", "export", "import"],
|
|
60
60
|
"tracking-link": ["list", "create", "read", "update", "delete", "export", "import"],
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
source: ["list", "create", "read", "update", "delete", "export", "import"],
|
|
62
|
+
medium: ["list", "create", "read", "update", "delete", "export", "import"],
|
|
63
63
|
"campaign-id": ["list", "create", "read", "update", "delete", "export", "import"],
|
|
64
64
|
"campaign-phase": ["list", "create", "read", "update", "delete", "export", "import"],
|
|
65
65
|
"campaign-product": ["list", "create", "read", "update", "delete", "export", "import"],
|
|
66
66
|
"campaign-key": ["list", "create", "read", "update", "delete", "export", "import"],
|
|
67
|
-
|
|
67
|
+
content: ["list", "create", "read", "update", "delete", "export", "import"],
|
|
68
68
|
"creative-format": ["list", "create", "read", "update", "delete", "export", "import"],
|
|
69
69
|
"creative-format-variant": ["list", "create", "read", "update", "delete", "export", "import"],
|
|
70
|
-
|
|
70
|
+
term: ["list", "create", "read", "update", "delete", "export", "import"]
|
|
71
71
|
};
|
|
72
72
|
var GROUP_ENTITY_KEYS = Object.keys(GROUP_ENTITY_PERMISSIONS);
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
var GROUP_ENTITY_SCOPES = makeGroupEntityScopes();
|
|
73
|
+
var GROUP_ENTITY_SCOPES = Object.entries(GROUP_ENTITY_PERMISSIONS).flatMap(
|
|
74
|
+
([entity, actions]) => actions.map((action) => `${entity}:${action}`)
|
|
75
|
+
);
|
|
79
76
|
function validateAndClean(schema, input) {
|
|
80
77
|
var _a, _b;
|
|
81
78
|
try {
|