@voltade/envoy-sdk 1.3.2 → 1.4.1
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 +14 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/resources/campaigns/index.d.ts.map +1 -1
- package/dist/resources/campaigns/index.js +2 -3
- package/dist/resources/campaigns/index.js.map +1 -1
- package/dist/resources/campaigns/types.d.ts +0 -3
- package/dist/resources/campaigns/types.d.ts.map +1 -1
- package/dist/resources/campaigns/types.js +0 -1
- package/dist/resources/campaigns/types.js.map +1 -1
- package/dist/resources/companies/index.d.ts +28 -3
- package/dist/resources/companies/index.d.ts.map +1 -1
- package/dist/resources/companies/index.js +42 -3
- package/dist/resources/companies/index.js.map +1 -1
- package/dist/resources/companies/types.d.ts +41 -0
- package/dist/resources/companies/types.d.ts.map +1 -1
- package/dist/resources/companies/types.js +4 -0
- package/dist/resources/companies/types.js.map +1 -1
- package/dist/resources/contacts/index.d.ts +36 -3
- package/dist/resources/contacts/index.d.ts.map +1 -1
- package/dist/resources/contacts/index.js +42 -2
- package/dist/resources/contacts/index.js.map +1 -1
- package/dist/resources/contacts/types.d.ts +41 -0
- package/dist/resources/contacts/types.d.ts.map +1 -1
- package/dist/resources/contacts/types.js +4 -0
- package/dist/resources/contacts/types.js.map +1 -1
- package/dist/resources/filters.d.ts +172 -0
- package/dist/resources/filters.d.ts.map +1 -0
- package/dist/resources/filters.js +299 -0
- package/dist/resources/filters.js.map +1 -0
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +1 -0
- package/dist/resources/index.js.map +1 -1
- package/dist/resources/orders/index.d.ts +29 -10
- package/dist/resources/orders/index.d.ts.map +1 -1
- package/dist/resources/orders/index.js +31 -12
- package/dist/resources/orders/index.js.map +1 -1
- package/dist/resources/orders/types.d.ts +234 -201
- package/dist/resources/orders/types.d.ts.map +1 -1
- package/dist/resources/orders/types.js +35 -13
- package/dist/resources/orders/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -52,13 +52,50 @@ export declare const ContactUpdateParamsSchema: z.ZodObject<{
|
|
|
52
52
|
}>;
|
|
53
53
|
export declare const ListContactsParamsSchema: z.ZodObject<{
|
|
54
54
|
page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
55
|
+
per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
55
56
|
sort: z.ZodOptional<z.ZodString>;
|
|
57
|
+
/** Filter conditions array */
|
|
58
|
+
filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
59
|
+
attribute_key: z.ZodString;
|
|
60
|
+
filter_operator: z.ZodEnum<["equal_to", "not_equal_to", "contains", "does_not_contain", "matches_phrase", "does_not_match_phrase", "starts_with", "is_present", "is_not_present", "is_greater_than", "is_less_than", "date_is", "date_is_before", "date_is_after", "date_is_between", "date_within_last_n", "date_within_next_n", "date_more_than_n_ago", "date_is_n_from_today", "in", "not_in"]>;
|
|
61
|
+
values: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">]>;
|
|
62
|
+
query_operator: z.ZodEnum<["and", "or"]>;
|
|
63
|
+
attribute_model: z.ZodOptional<z.ZodEnum<["standard", "customAttributes"]>>;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
values: string | number | boolean | (string | number)[];
|
|
66
|
+
attribute_key: string;
|
|
67
|
+
filter_operator: "equal_to" | "not_equal_to" | "contains" | "does_not_contain" | "matches_phrase" | "does_not_match_phrase" | "starts_with" | "is_present" | "is_not_present" | "is_greater_than" | "is_less_than" | "date_is" | "date_is_before" | "date_is_after" | "date_is_between" | "date_within_last_n" | "date_within_next_n" | "date_more_than_n_ago" | "date_is_n_from_today" | "in" | "not_in";
|
|
68
|
+
query_operator: "and" | "or";
|
|
69
|
+
attribute_model?: "standard" | "customAttributes" | undefined;
|
|
70
|
+
}, {
|
|
71
|
+
values: string | number | boolean | (string | number)[];
|
|
72
|
+
attribute_key: string;
|
|
73
|
+
filter_operator: "equal_to" | "not_equal_to" | "contains" | "does_not_contain" | "matches_phrase" | "does_not_match_phrase" | "starts_with" | "is_present" | "is_not_present" | "is_greater_than" | "is_less_than" | "date_is" | "date_is_before" | "date_is_after" | "date_is_between" | "date_within_last_n" | "date_within_next_n" | "date_more_than_n_ago" | "date_is_n_from_today" | "in" | "not_in";
|
|
74
|
+
query_operator: "and" | "or";
|
|
75
|
+
attribute_model?: "standard" | "customAttributes" | undefined;
|
|
76
|
+
}>, "many">>;
|
|
56
77
|
}, "strip", z.ZodTypeAny, {
|
|
57
78
|
page: number;
|
|
79
|
+
per_page: number;
|
|
58
80
|
sort?: string | undefined;
|
|
81
|
+
filters?: {
|
|
82
|
+
values: string | number | boolean | (string | number)[];
|
|
83
|
+
attribute_key: string;
|
|
84
|
+
filter_operator: "equal_to" | "not_equal_to" | "contains" | "does_not_contain" | "matches_phrase" | "does_not_match_phrase" | "starts_with" | "is_present" | "is_not_present" | "is_greater_than" | "is_less_than" | "date_is" | "date_is_before" | "date_is_after" | "date_is_between" | "date_within_last_n" | "date_within_next_n" | "date_more_than_n_ago" | "date_is_n_from_today" | "in" | "not_in";
|
|
85
|
+
query_operator: "and" | "or";
|
|
86
|
+
attribute_model?: "standard" | "customAttributes" | undefined;
|
|
87
|
+
}[] | undefined;
|
|
59
88
|
}, {
|
|
60
89
|
sort?: string | undefined;
|
|
90
|
+
filters?: {
|
|
91
|
+
values: string | number | boolean | (string | number)[];
|
|
92
|
+
attribute_key: string;
|
|
93
|
+
filter_operator: "equal_to" | "not_equal_to" | "contains" | "does_not_contain" | "matches_phrase" | "does_not_match_phrase" | "starts_with" | "is_present" | "is_not_present" | "is_greater_than" | "is_less_than" | "date_is" | "date_is_before" | "date_is_after" | "date_is_between" | "date_within_last_n" | "date_within_next_n" | "date_more_than_n_ago" | "date_is_n_from_today" | "in" | "not_in";
|
|
94
|
+
query_operator: "and" | "or";
|
|
95
|
+
attribute_model?: "standard" | "customAttributes" | undefined;
|
|
96
|
+
}[] | undefined;
|
|
61
97
|
page?: number | undefined;
|
|
98
|
+
per_page?: number | undefined;
|
|
62
99
|
}>;
|
|
63
100
|
export declare const ListContactsResponseSchema: z.ZodObject<{
|
|
64
101
|
payload: z.ZodArray<z.ZodObject<{
|
|
@@ -163,6 +200,10 @@ export declare const SearchContactsParamsSchema: z.ZodObject<{
|
|
|
163
200
|
sort?: string | undefined;
|
|
164
201
|
page?: number | undefined;
|
|
165
202
|
}>;
|
|
203
|
+
/**
|
|
204
|
+
* Contact filter attribute keys (standard fields)
|
|
205
|
+
*/
|
|
206
|
+
export type ContactFilterAttribute = "name" | "primary_email" | "phone_number" | "identifier" | "company_name" | "source" | "created_at" | "last_activity_at" | "first_message_at" | "blocked" | "customer_stage" | "labels" | (string & {});
|
|
166
207
|
/**
|
|
167
208
|
* TypeScript Types (inferred from Zod schemas)
|
|
168
209
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../resources/contacts/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,KAAK,OAAO,EACZ,KAAK,YAAY,EAClB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../resources/contacts/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,KAAK,OAAO,EACZ,KAAK,YAAY,EAClB,MAAM,2BAA2B,CAAC;AAGnC;;GAEG;AAGH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;EAkBpC,CAAC;AAGH,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|
3
|
+
import { FilterConditionSchema } from "../filters.js";
|
|
3
4
|
/**
|
|
4
5
|
* Zod Schemas for Contacts
|
|
5
6
|
*/
|
|
@@ -45,7 +46,10 @@ export const ContactUpdateParamsSchema = z.object({
|
|
|
45
46
|
// List contacts parameters schema
|
|
46
47
|
export const ListContactsParamsSchema = z.object({
|
|
47
48
|
page: z.number().int().positive().optional().default(1),
|
|
49
|
+
per_page: z.number().int().positive().max(100).optional().default(25),
|
|
48
50
|
sort: z.string().optional().describe("Sort order for contacts"),
|
|
51
|
+
/** Filter conditions array */
|
|
52
|
+
filters: z.array(FilterConditionSchema).optional(),
|
|
49
53
|
});
|
|
50
54
|
// List contacts response schema
|
|
51
55
|
export const ListContactsResponseSchema = z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../resources/contacts/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,aAAa,EACb,kBAAkB,GAGnB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../resources/contacts/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,aAAa,EACb,kBAAkB,GAGnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD;;GAEG;AAEH,mCAAmC;AACnC,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC;IAChD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IAC3D,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,E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AAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;CAChE,CAAC,CAAC;AA8BH,+CAA+C;AAC/C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Filter operators for text fields
|
|
4
|
+
*/
|
|
5
|
+
export declare const TextFilterOperatorSchema: z.ZodEnum<["equal_to", "not_equal_to", "contains", "does_not_contain", "matches_phrase", "does_not_match_phrase", "starts_with", "is_present", "is_not_present"]>;
|
|
6
|
+
/**
|
|
7
|
+
* Filter operators for number fields
|
|
8
|
+
*/
|
|
9
|
+
export declare const NumberFilterOperatorSchema: z.ZodEnum<["equal_to", "not_equal_to", "is_greater_than", "is_less_than"]>;
|
|
10
|
+
/**
|
|
11
|
+
* Filter operators for date fields
|
|
12
|
+
*/
|
|
13
|
+
export declare const DateFilterOperatorSchema: z.ZodEnum<["date_is", "date_is_before", "date_is_after", "date_is_between", "date_within_last_n", "date_within_next_n", "date_more_than_n_ago", "date_is_n_from_today"]>;
|
|
14
|
+
/**
|
|
15
|
+
* Filter operators for list/select fields
|
|
16
|
+
*/
|
|
17
|
+
export declare const ListFilterOperatorSchema: z.ZodEnum<["equal_to", "not_equal_to", "in", "not_in"]>;
|
|
18
|
+
/**
|
|
19
|
+
* Filter operators for boolean fields
|
|
20
|
+
*/
|
|
21
|
+
export declare const BooleanFilterOperatorSchema: z.ZodEnum<["equal_to", "not_equal_to"]>;
|
|
22
|
+
/**
|
|
23
|
+
* All possible filter operators
|
|
24
|
+
*/
|
|
25
|
+
export declare const FilterOperatorSchema: z.ZodEnum<["equal_to", "not_equal_to", "contains", "does_not_contain", "matches_phrase", "does_not_match_phrase", "starts_with", "is_present", "is_not_present", "is_greater_than", "is_less_than", "date_is", "date_is_before", "date_is_after", "date_is_between", "date_within_last_n", "date_within_next_n", "date_more_than_n_ago", "date_is_n_from_today", "in", "not_in"]>;
|
|
26
|
+
/**
|
|
27
|
+
* Query operator for combining conditions
|
|
28
|
+
*/
|
|
29
|
+
export declare const QueryOperatorSchema: z.ZodEnum<["and", "or"]>;
|
|
30
|
+
/**
|
|
31
|
+
* Attribute model type
|
|
32
|
+
*/
|
|
33
|
+
export declare const AttributeModelSchema: z.ZodEnum<["standard", "customAttributes"]>;
|
|
34
|
+
/**
|
|
35
|
+
* Date unit for relative date filters
|
|
36
|
+
*/
|
|
37
|
+
export declare const DateUnitSchema: z.ZodEnum<["days", "weeks", "months"]>;
|
|
38
|
+
/**
|
|
39
|
+
* Filter condition schema - the core building block
|
|
40
|
+
*/
|
|
41
|
+
export declare const FilterConditionSchema: z.ZodObject<{
|
|
42
|
+
/** Field to filter on */
|
|
43
|
+
attribute_key: z.ZodString;
|
|
44
|
+
/** Operator to use for comparison */
|
|
45
|
+
filter_operator: z.ZodEnum<["equal_to", "not_equal_to", "contains", "does_not_contain", "matches_phrase", "does_not_match_phrase", "starts_with", "is_present", "is_not_present", "is_greater_than", "is_less_than", "date_is", "date_is_before", "date_is_after", "date_is_between", "date_within_last_n", "date_within_next_n", "date_more_than_n_ago", "date_is_n_from_today", "in", "not_in"]>;
|
|
46
|
+
/** Value(s) to match - can be string, array, or tuple for date ranges */
|
|
47
|
+
values: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">]>;
|
|
48
|
+
/** How to combine with the NEXT condition (last one is ignored) */
|
|
49
|
+
query_operator: z.ZodEnum<["and", "or"]>;
|
|
50
|
+
/** Optional: specify if this is a standard or custom attribute */
|
|
51
|
+
attribute_model: z.ZodOptional<z.ZodEnum<["standard", "customAttributes"]>>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
values: string | number | boolean | (string | number)[];
|
|
54
|
+
attribute_key: string;
|
|
55
|
+
filter_operator: "equal_to" | "not_equal_to" | "contains" | "does_not_contain" | "matches_phrase" | "does_not_match_phrase" | "starts_with" | "is_present" | "is_not_present" | "is_greater_than" | "is_less_than" | "date_is" | "date_is_before" | "date_is_after" | "date_is_between" | "date_within_last_n" | "date_within_next_n" | "date_more_than_n_ago" | "date_is_n_from_today" | "in" | "not_in";
|
|
56
|
+
query_operator: "and" | "or";
|
|
57
|
+
attribute_model?: "standard" | "customAttributes" | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
values: string | number | boolean | (string | number)[];
|
|
60
|
+
attribute_key: string;
|
|
61
|
+
filter_operator: "equal_to" | "not_equal_to" | "contains" | "does_not_contain" | "matches_phrase" | "does_not_match_phrase" | "starts_with" | "is_present" | "is_not_present" | "is_greater_than" | "is_less_than" | "date_is" | "date_is_before" | "date_is_after" | "date_is_between" | "date_within_last_n" | "date_within_next_n" | "date_more_than_n_ago" | "date_is_n_from_today" | "in" | "not_in";
|
|
62
|
+
query_operator: "and" | "or";
|
|
63
|
+
attribute_model?: "standard" | "customAttributes" | undefined;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* TypeScript Types
|
|
67
|
+
*/
|
|
68
|
+
export type TextFilterOperator = z.infer<typeof TextFilterOperatorSchema>;
|
|
69
|
+
export type NumberFilterOperator = z.infer<typeof NumberFilterOperatorSchema>;
|
|
70
|
+
export type DateFilterOperator = z.infer<typeof DateFilterOperatorSchema>;
|
|
71
|
+
export type ListFilterOperator = z.infer<typeof ListFilterOperatorSchema>;
|
|
72
|
+
export type BooleanFilterOperator = z.infer<typeof BooleanFilterOperatorSchema>;
|
|
73
|
+
export type FilterOperator = z.infer<typeof FilterOperatorSchema>;
|
|
74
|
+
export type QueryOperator = z.infer<typeof QueryOperatorSchema>;
|
|
75
|
+
export type AttributeModel = z.infer<typeof AttributeModelSchema>;
|
|
76
|
+
export type DateUnit = z.infer<typeof DateUnitSchema>;
|
|
77
|
+
export type FilterCondition = z.infer<typeof FilterConditionSchema>;
|
|
78
|
+
/**
|
|
79
|
+
* Helper type for building filters with better DX
|
|
80
|
+
*/
|
|
81
|
+
export type FilterValue = string | number | boolean | string[] | number[] | [number, DateUnit];
|
|
82
|
+
/**
|
|
83
|
+
* Helper functions for creating filter conditions
|
|
84
|
+
*/
|
|
85
|
+
export declare const filters: {
|
|
86
|
+
/**
|
|
87
|
+
* Create a text equality filter
|
|
88
|
+
*/
|
|
89
|
+
eq: (key: string, value: string | string[], queryOp?: QueryOperator) => FilterCondition;
|
|
90
|
+
/**
|
|
91
|
+
* Create a text not equal filter
|
|
92
|
+
*/
|
|
93
|
+
notEq: (key: string, value: string | string[], queryOp?: QueryOperator) => FilterCondition;
|
|
94
|
+
/**
|
|
95
|
+
* Create a contains filter (text fields)
|
|
96
|
+
*/
|
|
97
|
+
contains: (key: string, value: string, queryOp?: QueryOperator) => FilterCondition;
|
|
98
|
+
/**
|
|
99
|
+
* Create a does not contain filter (text fields)
|
|
100
|
+
*/
|
|
101
|
+
notContains: (key: string, value: string, queryOp?: QueryOperator) => FilterCondition;
|
|
102
|
+
/**
|
|
103
|
+
* Create a starts with filter
|
|
104
|
+
*/
|
|
105
|
+
startsWith: (key: string, value: string, queryOp?: QueryOperator) => FilterCondition;
|
|
106
|
+
/**
|
|
107
|
+
* Create a "value is present" filter
|
|
108
|
+
*/
|
|
109
|
+
isPresent: (key: string, queryOp?: QueryOperator) => FilterCondition;
|
|
110
|
+
/**
|
|
111
|
+
* Create a "value is not present" filter
|
|
112
|
+
*/
|
|
113
|
+
isNotPresent: (key: string, queryOp?: QueryOperator) => FilterCondition;
|
|
114
|
+
/**
|
|
115
|
+
* Create an "in list" filter
|
|
116
|
+
*/
|
|
117
|
+
in: (key: string, values: string[], queryOp?: QueryOperator) => FilterCondition;
|
|
118
|
+
/**
|
|
119
|
+
* Create a "not in list" filter
|
|
120
|
+
*/
|
|
121
|
+
notIn: (key: string, values: string[], queryOp?: QueryOperator) => FilterCondition;
|
|
122
|
+
/**
|
|
123
|
+
* Create a greater than filter (number fields)
|
|
124
|
+
*/
|
|
125
|
+
gt: (key: string, value: number, queryOp?: QueryOperator) => FilterCondition;
|
|
126
|
+
/**
|
|
127
|
+
* Create a less than filter (number fields)
|
|
128
|
+
*/
|
|
129
|
+
lt: (key: string, value: number, queryOp?: QueryOperator) => FilterCondition;
|
|
130
|
+
/**
|
|
131
|
+
* Create a date equals filter
|
|
132
|
+
*/
|
|
133
|
+
dateIs: (key: string, date: string, queryOp?: QueryOperator) => FilterCondition;
|
|
134
|
+
/**
|
|
135
|
+
* Create a date before filter
|
|
136
|
+
*/
|
|
137
|
+
dateBefore: (key: string, date: string, queryOp?: QueryOperator) => FilterCondition;
|
|
138
|
+
/**
|
|
139
|
+
* Create a date after filter
|
|
140
|
+
*/
|
|
141
|
+
dateAfter: (key: string, date: string, queryOp?: QueryOperator) => FilterCondition;
|
|
142
|
+
/**
|
|
143
|
+
* Create a date between filter
|
|
144
|
+
*/
|
|
145
|
+
dateBetween: (key: string, startDate: string, endDate: string, queryOp?: QueryOperator) => FilterCondition;
|
|
146
|
+
/**
|
|
147
|
+
* Create a "within last N days/weeks/months" filter
|
|
148
|
+
*/
|
|
149
|
+
dateWithinLast: (key: string, n: number, unit: DateUnit, queryOp?: QueryOperator) => FilterCondition;
|
|
150
|
+
/**
|
|
151
|
+
* Create a "within next N days/weeks/months" filter
|
|
152
|
+
*/
|
|
153
|
+
dateWithinNext: (key: string, n: number, unit: DateUnit, queryOp?: QueryOperator) => FilterCondition;
|
|
154
|
+
/**
|
|
155
|
+
* Create a "more than N ago" filter
|
|
156
|
+
*/
|
|
157
|
+
dateMoreThanAgo: (key: string, n: number, unit: DateUnit, queryOp?: QueryOperator) => FilterCondition;
|
|
158
|
+
/**
|
|
159
|
+
* Create a custom attribute filter
|
|
160
|
+
*/
|
|
161
|
+
custom: (key: string, operator: FilterOperator, values: FilterValue, queryOp?: QueryOperator) => FilterCondition;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Sorting helpers
|
|
165
|
+
*/
|
|
166
|
+
export declare const sort: {
|
|
167
|
+
/** Sort ascending */
|
|
168
|
+
asc: (field: string) => string;
|
|
169
|
+
/** Sort descending */
|
|
170
|
+
desc: (field: string) => string;
|
|
171
|
+
};
|
|
172
|
+
//# sourceMappingURL=filters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../resources/filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,wBAAwB,mKAUnC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,0BAA0B,4EAKrC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB,0KASnC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB,yDAKnC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,2BAA2B,yCAAuC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,oBAAoB,mXA0B/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB,0BAAwB,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,oBAAoB,6CAA2C,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,cAAc,wCAAsC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAChC,yBAAyB;;IAEzB,qCAAqC;;IAErC,yEAAyE;;IAOzE,mEAAmE;;IAEnE,kEAAkE;;;;;;;;;;;;;;EAElE,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,kBAAkB,GAAG,CA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Ae;IAOlB;;OAEG;iBAEI,MAAM,UACH,MAAM,EAAE,YACP,aAAa,KACrB,eAAe;IAOlB;;OAEG;cAEI,MAAM,SACJ,MAAM,YACJ,aAAa,KACrB,eAAe;IAOlB;;OAEG;cAEI,MAAM,SACJ,MAAM,YACJ,aAAa,KACrB,eAAe;IAOlB;;OAEG;kBAEI,MAAM,QACL,MAAM,YACH,aAAa,KACrB,eAAe;IAOlB;;OAEG;sBAEI,MAAM,QACL,MAAM,YACH,aAAa,KACrB,eAAe;IAOlB;;OAEG;qBAEI,MAAM,QACL,MAAM,YACH,aAAa,KACrB,eAAe;IAOlB;;OAEG;uBAEI,MAAM,aACA,MAAM,WACR,MAAM,YACN,aAAa,KACrB,eAAe;IAOlB;;OAEG;0BAEI,MAAM,KACR,MAAM,QACH,QAAQ,YACL,aAAa,KACrB,eAAe;IAOlB;;OAEG;0BAEI,MAAM,KACR,MAAM,QACH,QAAQ,YACL,aAAa,KACrB,eAAe;IAOlB;;OAEG;2BAEI,MAAM,KACR,MAAM,QACH,QAAQ,YACL,aAAa,KACrB,eAAe;IAOlB;;OAEG;kBAEI,MAAM,YACD,cAAc,UAChB,WAAW,YACV,aAAa,KACrB,eAAe;CAOnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,IAAI;IACf,qBAAqB;iBACR,MAAM;IACnB,sBAAsB;kBACR,MAAM;CACrB,CAAC"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Filter operators for text fields
|
|
4
|
+
*/
|
|
5
|
+
export const TextFilterOperatorSchema = z.enum([
|
|
6
|
+
"equal_to",
|
|
7
|
+
"not_equal_to",
|
|
8
|
+
"contains",
|
|
9
|
+
"does_not_contain",
|
|
10
|
+
"matches_phrase",
|
|
11
|
+
"does_not_match_phrase",
|
|
12
|
+
"starts_with",
|
|
13
|
+
"is_present",
|
|
14
|
+
"is_not_present",
|
|
15
|
+
]);
|
|
16
|
+
/**
|
|
17
|
+
* Filter operators for number fields
|
|
18
|
+
*/
|
|
19
|
+
export const NumberFilterOperatorSchema = z.enum([
|
|
20
|
+
"equal_to",
|
|
21
|
+
"not_equal_to",
|
|
22
|
+
"is_greater_than",
|
|
23
|
+
"is_less_than",
|
|
24
|
+
]);
|
|
25
|
+
/**
|
|
26
|
+
* Filter operators for date fields
|
|
27
|
+
*/
|
|
28
|
+
export const DateFilterOperatorSchema = z.enum([
|
|
29
|
+
"date_is",
|
|
30
|
+
"date_is_before",
|
|
31
|
+
"date_is_after",
|
|
32
|
+
"date_is_between",
|
|
33
|
+
"date_within_last_n",
|
|
34
|
+
"date_within_next_n",
|
|
35
|
+
"date_more_than_n_ago",
|
|
36
|
+
"date_is_n_from_today",
|
|
37
|
+
]);
|
|
38
|
+
/**
|
|
39
|
+
* Filter operators for list/select fields
|
|
40
|
+
*/
|
|
41
|
+
export const ListFilterOperatorSchema = z.enum([
|
|
42
|
+
"equal_to",
|
|
43
|
+
"not_equal_to",
|
|
44
|
+
"in",
|
|
45
|
+
"not_in",
|
|
46
|
+
]);
|
|
47
|
+
/**
|
|
48
|
+
* Filter operators for boolean fields
|
|
49
|
+
*/
|
|
50
|
+
export const BooleanFilterOperatorSchema = z.enum(["equal_to", "not_equal_to"]);
|
|
51
|
+
/**
|
|
52
|
+
* All possible filter operators
|
|
53
|
+
*/
|
|
54
|
+
export const FilterOperatorSchema = z.enum([
|
|
55
|
+
// Text
|
|
56
|
+
"equal_to",
|
|
57
|
+
"not_equal_to",
|
|
58
|
+
"contains",
|
|
59
|
+
"does_not_contain",
|
|
60
|
+
"matches_phrase",
|
|
61
|
+
"does_not_match_phrase",
|
|
62
|
+
"starts_with",
|
|
63
|
+
"is_present",
|
|
64
|
+
"is_not_present",
|
|
65
|
+
// Number
|
|
66
|
+
"is_greater_than",
|
|
67
|
+
"is_less_than",
|
|
68
|
+
// Date
|
|
69
|
+
"date_is",
|
|
70
|
+
"date_is_before",
|
|
71
|
+
"date_is_after",
|
|
72
|
+
"date_is_between",
|
|
73
|
+
"date_within_last_n",
|
|
74
|
+
"date_within_next_n",
|
|
75
|
+
"date_more_than_n_ago",
|
|
76
|
+
"date_is_n_from_today",
|
|
77
|
+
// List
|
|
78
|
+
"in",
|
|
79
|
+
"not_in",
|
|
80
|
+
]);
|
|
81
|
+
/**
|
|
82
|
+
* Query operator for combining conditions
|
|
83
|
+
*/
|
|
84
|
+
export const QueryOperatorSchema = z.enum(["and", "or"]);
|
|
85
|
+
/**
|
|
86
|
+
* Attribute model type
|
|
87
|
+
*/
|
|
88
|
+
export const AttributeModelSchema = z.enum(["standard", "customAttributes"]);
|
|
89
|
+
/**
|
|
90
|
+
* Date unit for relative date filters
|
|
91
|
+
*/
|
|
92
|
+
export const DateUnitSchema = z.enum(["days", "weeks", "months"]);
|
|
93
|
+
/**
|
|
94
|
+
* Filter condition schema - the core building block
|
|
95
|
+
*/
|
|
96
|
+
export const FilterConditionSchema = z.object({
|
|
97
|
+
/** Field to filter on */
|
|
98
|
+
attribute_key: z.string(),
|
|
99
|
+
/** Operator to use for comparison */
|
|
100
|
+
filter_operator: FilterOperatorSchema,
|
|
101
|
+
/** Value(s) to match - can be string, array, or tuple for date ranges */
|
|
102
|
+
values: z.union([
|
|
103
|
+
z.string(),
|
|
104
|
+
z.number(),
|
|
105
|
+
z.boolean(),
|
|
106
|
+
z.array(z.union([z.string(), z.number()])),
|
|
107
|
+
]),
|
|
108
|
+
/** How to combine with the NEXT condition (last one is ignored) */
|
|
109
|
+
query_operator: QueryOperatorSchema,
|
|
110
|
+
/** Optional: specify if this is a standard or custom attribute */
|
|
111
|
+
attribute_model: AttributeModelSchema.optional(),
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* Helper functions for creating filter conditions
|
|
115
|
+
*/
|
|
116
|
+
export const filters = {
|
|
117
|
+
/**
|
|
118
|
+
* Create a text equality filter
|
|
119
|
+
*/
|
|
120
|
+
eq: (key, value, queryOp = "and") => ({
|
|
121
|
+
attribute_key: key,
|
|
122
|
+
filter_operator: "equal_to",
|
|
123
|
+
values: Array.isArray(value) ? value : value,
|
|
124
|
+
query_operator: queryOp,
|
|
125
|
+
}),
|
|
126
|
+
/**
|
|
127
|
+
* Create a text not equal filter
|
|
128
|
+
*/
|
|
129
|
+
notEq: (key, value, queryOp = "and") => ({
|
|
130
|
+
attribute_key: key,
|
|
131
|
+
filter_operator: "not_equal_to",
|
|
132
|
+
values: Array.isArray(value) ? value : value,
|
|
133
|
+
query_operator: queryOp,
|
|
134
|
+
}),
|
|
135
|
+
/**
|
|
136
|
+
* Create a contains filter (text fields)
|
|
137
|
+
*/
|
|
138
|
+
contains: (key, value, queryOp = "and") => ({
|
|
139
|
+
attribute_key: key,
|
|
140
|
+
filter_operator: "contains",
|
|
141
|
+
values: value,
|
|
142
|
+
query_operator: queryOp,
|
|
143
|
+
}),
|
|
144
|
+
/**
|
|
145
|
+
* Create a does not contain filter (text fields)
|
|
146
|
+
*/
|
|
147
|
+
notContains: (key, value, queryOp = "and") => ({
|
|
148
|
+
attribute_key: key,
|
|
149
|
+
filter_operator: "does_not_contain",
|
|
150
|
+
values: value,
|
|
151
|
+
query_operator: queryOp,
|
|
152
|
+
}),
|
|
153
|
+
/**
|
|
154
|
+
* Create a starts with filter
|
|
155
|
+
*/
|
|
156
|
+
startsWith: (key, value, queryOp = "and") => ({
|
|
157
|
+
attribute_key: key,
|
|
158
|
+
filter_operator: "starts_with",
|
|
159
|
+
values: value,
|
|
160
|
+
query_operator: queryOp,
|
|
161
|
+
}),
|
|
162
|
+
/**
|
|
163
|
+
* Create a "value is present" filter
|
|
164
|
+
*/
|
|
165
|
+
isPresent: (key, queryOp = "and") => ({
|
|
166
|
+
attribute_key: key,
|
|
167
|
+
filter_operator: "is_present",
|
|
168
|
+
values: "",
|
|
169
|
+
query_operator: queryOp,
|
|
170
|
+
}),
|
|
171
|
+
/**
|
|
172
|
+
* Create a "value is not present" filter
|
|
173
|
+
*/
|
|
174
|
+
isNotPresent: (key, queryOp = "and") => ({
|
|
175
|
+
attribute_key: key,
|
|
176
|
+
filter_operator: "is_not_present",
|
|
177
|
+
values: "",
|
|
178
|
+
query_operator: queryOp,
|
|
179
|
+
}),
|
|
180
|
+
/**
|
|
181
|
+
* Create an "in list" filter
|
|
182
|
+
*/
|
|
183
|
+
in: (key, values, queryOp = "and") => ({
|
|
184
|
+
attribute_key: key,
|
|
185
|
+
filter_operator: "in",
|
|
186
|
+
values,
|
|
187
|
+
query_operator: queryOp,
|
|
188
|
+
}),
|
|
189
|
+
/**
|
|
190
|
+
* Create a "not in list" filter
|
|
191
|
+
*/
|
|
192
|
+
notIn: (key, values, queryOp = "and") => ({
|
|
193
|
+
attribute_key: key,
|
|
194
|
+
filter_operator: "not_in",
|
|
195
|
+
values,
|
|
196
|
+
query_operator: queryOp,
|
|
197
|
+
}),
|
|
198
|
+
/**
|
|
199
|
+
* Create a greater than filter (number fields)
|
|
200
|
+
*/
|
|
201
|
+
gt: (key, value, queryOp = "and") => ({
|
|
202
|
+
attribute_key: key,
|
|
203
|
+
filter_operator: "is_greater_than",
|
|
204
|
+
values: value.toString(),
|
|
205
|
+
query_operator: queryOp,
|
|
206
|
+
}),
|
|
207
|
+
/**
|
|
208
|
+
* Create a less than filter (number fields)
|
|
209
|
+
*/
|
|
210
|
+
lt: (key, value, queryOp = "and") => ({
|
|
211
|
+
attribute_key: key,
|
|
212
|
+
filter_operator: "is_less_than",
|
|
213
|
+
values: value.toString(),
|
|
214
|
+
query_operator: queryOp,
|
|
215
|
+
}),
|
|
216
|
+
/**
|
|
217
|
+
* Create a date equals filter
|
|
218
|
+
*/
|
|
219
|
+
dateIs: (key, date, queryOp = "and") => ({
|
|
220
|
+
attribute_key: key,
|
|
221
|
+
filter_operator: "date_is",
|
|
222
|
+
values: date,
|
|
223
|
+
query_operator: queryOp,
|
|
224
|
+
}),
|
|
225
|
+
/**
|
|
226
|
+
* Create a date before filter
|
|
227
|
+
*/
|
|
228
|
+
dateBefore: (key, date, queryOp = "and") => ({
|
|
229
|
+
attribute_key: key,
|
|
230
|
+
filter_operator: "date_is_before",
|
|
231
|
+
values: date,
|
|
232
|
+
query_operator: queryOp,
|
|
233
|
+
}),
|
|
234
|
+
/**
|
|
235
|
+
* Create a date after filter
|
|
236
|
+
*/
|
|
237
|
+
dateAfter: (key, date, queryOp = "and") => ({
|
|
238
|
+
attribute_key: key,
|
|
239
|
+
filter_operator: "date_is_after",
|
|
240
|
+
values: date,
|
|
241
|
+
query_operator: queryOp,
|
|
242
|
+
}),
|
|
243
|
+
/**
|
|
244
|
+
* Create a date between filter
|
|
245
|
+
*/
|
|
246
|
+
dateBetween: (key, startDate, endDate, queryOp = "and") => ({
|
|
247
|
+
attribute_key: key,
|
|
248
|
+
filter_operator: "date_is_between",
|
|
249
|
+
values: [startDate, endDate],
|
|
250
|
+
query_operator: queryOp,
|
|
251
|
+
}),
|
|
252
|
+
/**
|
|
253
|
+
* Create a "within last N days/weeks/months" filter
|
|
254
|
+
*/
|
|
255
|
+
dateWithinLast: (key, n, unit, queryOp = "and") => ({
|
|
256
|
+
attribute_key: key,
|
|
257
|
+
filter_operator: "date_within_last_n",
|
|
258
|
+
values: [n, unit],
|
|
259
|
+
query_operator: queryOp,
|
|
260
|
+
}),
|
|
261
|
+
/**
|
|
262
|
+
* Create a "within next N days/weeks/months" filter
|
|
263
|
+
*/
|
|
264
|
+
dateWithinNext: (key, n, unit, queryOp = "and") => ({
|
|
265
|
+
attribute_key: key,
|
|
266
|
+
filter_operator: "date_within_next_n",
|
|
267
|
+
values: [n, unit],
|
|
268
|
+
query_operator: queryOp,
|
|
269
|
+
}),
|
|
270
|
+
/**
|
|
271
|
+
* Create a "more than N ago" filter
|
|
272
|
+
*/
|
|
273
|
+
dateMoreThanAgo: (key, n, unit, queryOp = "and") => ({
|
|
274
|
+
attribute_key: key,
|
|
275
|
+
filter_operator: "date_more_than_n_ago",
|
|
276
|
+
values: [n, unit],
|
|
277
|
+
query_operator: queryOp,
|
|
278
|
+
}),
|
|
279
|
+
/**
|
|
280
|
+
* Create a custom attribute filter
|
|
281
|
+
*/
|
|
282
|
+
custom: (key, operator, values, queryOp = "and") => ({
|
|
283
|
+
attribute_key: key,
|
|
284
|
+
filter_operator: operator,
|
|
285
|
+
values: values,
|
|
286
|
+
query_operator: queryOp,
|
|
287
|
+
attribute_model: "customAttributes",
|
|
288
|
+
}),
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* Sorting helpers
|
|
292
|
+
*/
|
|
293
|
+
export const sort = {
|
|
294
|
+
/** Sort ascending */
|
|
295
|
+
asc: (field) => field,
|
|
296
|
+
/** Sort descending */
|
|
297
|
+
desc: (field) => `-${field}`,
|
|
298
|
+
};
|
|
299
|
+
//# sourceMappingURL=filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../resources/filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC7C,UAAU;IACV,cAAc;IACd,UAAU;IACV,kBAAkB;IAClB,gBAAgB;IAChB,uBAAuB;IACvB,aAAa;IACb,YAAY;IACZ,gBAAgB;CACjB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,IAAI,CAAC;IAC/C,UAAU;IACV,cAAc;IACd,iBAAiB;IACjB,cAAc;CACf,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC7C,SAAS;IACT,gBAAgB;IAChB,eAAe;IACf,iBAAiB;IACjB,oBAAoB;IACpB,oBAAoB;IACpB,sBAAsB;IACtB,sBAAsB;CACvB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,C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E,CAAC,CAAC;QACrB,aAAa,EAAE,GAAG;QAClB,eAAe,EAAE,oBAAoB;QACrC,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;QACjB,cAAc,EAAE,OAAO;KACxB,CAAC;IAEF;;OAEG;IACH,cAAc,EAAE,CACd,GAAW,EACX,CAAS,EACT,IAAc,EACd,UAAyB,KAAK,EACb,EAAE,CAAC,CAAC;QACrB,aAAa,EAAE,GAAG;QAClB,eAAe,EAAE,oBAAoB;QACrC,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;QACjB,cAAc,EAAE,OAAO;KACxB,CAAC;IAEF;;OAEG;IACH,eAAe,EAAE,CACf,GAAW,EACX,CAAS,EACT,IAAc,EACd,UAAyB,KAAK,EACb,EAAE,CAAC,CAAC;QACrB,aAAa,EAAE,GAAG;QAClB,eAAe,EAAE,sBAAsB;QACvC,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;QACjB,cAAc,EAAE,OAAO;KACxB,CAAC;IAEF;;OAEG;IACH,MAAM,EAAE,CACN,GAAW,EACX,QAAwB,EACxB,MAAmB,EACnB,UAAyB,KAAK,EACb,EAAE,CAAC,CAAC;QACrB,aAAa,EAAE,GAAG;QAClB,eAAe,EAAE,QAAQ;QACzB,MAAM,EAAE,MAAmC;QAC3C,cAAc,EAAE,OAAO;QACvB,eAAe,EAAE,kBAAkB;KACpC,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,qBAAqB;IACrB,GAAG,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK;IAC7B,sBAAsB;IACtB,IAAI,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE;CACrC,CAAC"}
|
|
@@ -7,6 +7,7 @@ export * from "./companies/index.js";
|
|
|
7
7
|
export * from "./company-members/index.js";
|
|
8
8
|
export * from "./contacts/index.js";
|
|
9
9
|
export * from "./conversations/index.js";
|
|
10
|
+
export * from "./filters.js";
|
|
10
11
|
export * from "./inboxes/index.js";
|
|
11
12
|
export * from "./orders/index.js";
|
|
12
13
|
export * from "./webhooks/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../resources/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../resources/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
package/dist/resources/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./companies/index.js";
|
|
|
7
7
|
export * from "./company-members/index.js";
|
|
8
8
|
export * from "./contacts/index.js";
|
|
9
9
|
export * from "./conversations/index.js";
|
|
10
|
+
export * from "./filters.js";
|
|
10
11
|
export * from "./inboxes/index.js";
|
|
11
12
|
export * from "./orders/index.js";
|
|
12
13
|
export * from "./webhooks/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../resources/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../resources/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|