@based/functions 1.1.2 → 1.2.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/client.d.ts CHANGED
@@ -3,12 +3,15 @@ import { BasedChannel } from './channel';
3
3
  import { Context } from './context';
4
4
  import { BasedQuery } from './query';
5
5
  import { StreamFunctionOpts } from './stream';
6
+ import { Geo } from './geo';
6
7
  export declare abstract class BasedFunctionClient {
7
8
  server: any;
9
+ db: any;
8
10
  abstract call(name: string, payload?: any, ctx?: Context): Promise<any>;
9
11
  abstract query(name: string, payload?: any): BasedQuery;
10
12
  abstract channel(name: string, payload?: any): BasedChannel;
11
13
  abstract stream(name: string, payload: StreamFunctionOpts, ctx?: Context): Promise<any>;
12
14
  abstract sendAuthState(ctx: Context, authState: AuthState): void;
15
+ abstract geo(ctx: Context): Promise<Geo>;
13
16
  abstract renewAuthState(ctx: Context, authState?: AuthState): Promise<AuthState>;
14
17
  }
package/dist/client.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BasedFunctionClient = void 0;
4
- // TODO: this is the place where we will add extra specifications
5
4
  class BasedFunctionClient {
6
5
  }
7
6
  exports.BasedFunctionClient = BasedFunctionClient;
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAMA,iEAAiE;AACjE,MAAsB,mBAAmB;CAqBxC;AArBD,kDAqBC"}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAOA,MAAsB,mBAAmB;CAyBxC;AAzBD,kDAyBC"}
package/dist/geo.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ export type CountryCode = 'AF' | 'AL' | 'DZ' | 'AS' | 'AD' | 'AO' | 'AI' | 'AQ' | 'AG' | 'AR' | 'AM' | 'AW' | 'AU' | 'AT' | 'AZ' | 'BS' | 'BH' | 'BD' | 'BB' | 'BY' | 'BE' | 'BZ' | 'BJ' | 'BM' | 'BT' | 'BO' | 'BQ' | 'BA' | 'BW' | 'BV' | 'BR' | 'IO' | 'BN' | 'BG' | 'BF' | 'BI' | 'KH' | 'CM' | 'CA' | 'CV' | 'KY' | 'CF' | 'TD' | 'CL' | 'CN' | 'CX' | 'CC' | 'CO' | 'KM' | 'CG' | 'CD' | 'CK' | 'CR' | 'HR' | 'CU' | 'CW' | 'CY' | 'CZ' | 'CI' | 'DK' | 'DJ' | 'DM' | 'DO' | 'EC' | 'EG' | 'SV' | 'GQ' | 'ER' | 'EE' | 'ET' | 'FK' | 'FO' | 'FJ' | 'FI' | 'FR' | 'GF' | 'PF' | 'TF' | 'GA' | 'GM' | 'GE' | 'DE' | 'GH' | 'GI' | 'GR' | 'GL' | 'GD' | 'GP' | 'GU' | 'GT' | 'GG' | 'GN' | 'GW' | 'GY' | 'HT' | 'HM' | 'VA' | 'HN' | 'HK' | 'HU' | 'IS' | 'IN' | 'ID' | 'IR' | 'IQ' | 'IE' | 'IM' | 'IL' | 'IT' | 'JM' | 'JP' | 'JE' | 'JO' | 'KZ' | 'KE' | 'KI' | 'KP' | 'KR' | 'KW' | 'KG' | 'LA' | 'LV' | 'LB' | 'LS' | 'LR' | 'LY' | 'LI' | 'LT' | 'LU' | 'MO' | 'MK' | 'MG' | 'MW' | 'MY' | 'MV' | 'ML' | 'MT' | 'MH' | 'MQ' | 'MR' | 'MU' | 'YT' | 'MX' | 'FM' | 'MD' | 'MC' | 'MN' | 'ME' | 'MS' | 'MA' | 'MZ' | 'MM' | 'NA' | 'NR' | 'NP' | 'NL' | 'NC' | 'NZ' | 'NI' | 'NE' | 'NG' | 'NU' | 'NF' | 'MP' | 'NO' | 'OM' | 'PK' | 'PW' | 'PS' | 'PA' | 'PG' | 'PY' | 'PE' | 'PH' | 'PN' | 'PL' | 'PT' | 'PR' | 'QA' | 'RO' | 'RU' | 'RW' | 'RE' | 'BL' | 'SH' | 'KN' | 'LC' | 'MF' | 'PM' | 'VC' | 'WS' | 'SM' | 'ST' | 'SA' | 'SN' | 'RS' | 'SC' | 'SL' | 'SG' | 'SX' | 'SK' | 'SI' | 'SB' | 'SO' | 'ZA' | 'GS' | 'SS' | 'ES' | 'LK' | 'SD' | 'SR' | 'SJ' | 'SZ' | 'SE' | 'CH' | 'SY' | 'TW' | 'TJ' | 'TZ' | 'TH' | 'TL' | 'TG' | 'TK' | 'TO' | 'TT' | 'TN' | 'TR' | 'TM' | 'TC' | 'TV' | 'UG' | 'UA' | 'AE' | 'GB' | 'US' | 'UM' | 'UY' | 'UZ' | 'VU' | 'VE' | 'VN' | 'VG' | 'VI' | 'WF' | 'EH' | 'YE' | 'ZM' | 'ZW' | 'AX';
2
+ type Char = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
3
+ export type GeoRegionISO = `${Char}${Char}` | `${Char}${Char}${Char}`;
4
+ export type Geo = {
5
+ country: CountryCode;
6
+ /**
7
+ Ip formatted as ipv6
8
+
9
+ e.g. `2001:0db8:85a3:0000:0000:8a2e:0370:7334`
10
+ */
11
+ ip: string;
12
+ /**
13
+ Region subdivisions
14
+
15
+ e.g. `[{ iso: 'NH', name: 'north-holland' }]`
16
+ */
17
+ regions: {
18
+ iso: GeoRegionISO;
19
+ name?: string;
20
+ }[];
21
+ lat: number;
22
+ long: number;
23
+ /**
24
+ Accuracy Radius (km)
25
+ */
26
+ accuracy: number;
27
+ /**
28
+ City name
29
+
30
+ e.g. `Amsterdam`
31
+ */
32
+ city?: string;
33
+ postalCode?: string;
34
+ };
35
+ export {};
package/dist/geo.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=geo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geo.js","sourceRoot":"","sources":["../src/geo.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * from './functions';
5
5
  export * from './query';
6
6
  export * from './stream';
7
7
  export * from './channel';
8
+ export * from './geo';
package/dist/index.js CHANGED
@@ -21,4 +21,5 @@ __exportStar(require("./functions"), exports);
21
21
  __exportStar(require("./query"), exports);
22
22
  __exportStar(require("./stream"), exports);
23
23
  __exportStar(require("./channel"), exports);
24
+ __exportStar(require("./geo"), exports);
24
25
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,yCAAsB;AACtB,2CAAwB;AACxB,8CAA2B;AAC3B,0CAAuB;AACvB,2CAAwB;AACxB,4CAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,yCAAsB;AACtB,2CAAwB;AACxB,8CAA2B;AAC3B,0CAAuB;AACvB,2CAAwB;AACxB,4CAAyB;AACzB,wCAAqB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@based/functions",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/client.ts CHANGED
@@ -3,11 +3,13 @@ import { BasedChannel } from './channel'
3
3
  import { Context } from './context'
4
4
  import { BasedQuery } from './query'
5
5
  import { StreamFunctionOpts } from './stream'
6
+ import { Geo } from './geo'
6
7
 
7
- // TODO: this is the place where we will add extra specifications
8
8
  export abstract class BasedFunctionClient {
9
9
  server: any
10
10
 
11
+ db: any
12
+
11
13
  abstract call(name: string, payload?: any, ctx?: Context): Promise<any>
12
14
 
13
15
  abstract query(name: string, payload?: any): BasedQuery
@@ -22,6 +24,8 @@ export abstract class BasedFunctionClient {
22
24
 
23
25
  abstract sendAuthState(ctx: Context, authState: AuthState): void
24
26
 
27
+ abstract geo(ctx: Context): Promise<Geo>
28
+
25
29
  abstract renewAuthState(
26
30
  ctx: Context,
27
31
  authState?: AuthState
package/src/geo.ts ADDED
@@ -0,0 +1,322 @@
1
+ export type CountryCode =
2
+ | 'AF'
3
+ | 'AL'
4
+ | 'DZ'
5
+ | 'AS'
6
+ | 'AD'
7
+ | 'AO'
8
+ | 'AI'
9
+ | 'AQ'
10
+ | 'AG'
11
+ | 'AR'
12
+ | 'AM'
13
+ | 'AW'
14
+ | 'AU'
15
+ | 'AT'
16
+ | 'AZ'
17
+ | 'BS'
18
+ | 'BH'
19
+ | 'BD'
20
+ | 'BB'
21
+ | 'BY'
22
+ | 'BE'
23
+ | 'BZ'
24
+ | 'BJ'
25
+ | 'BM'
26
+ | 'BT'
27
+ | 'BO'
28
+ | 'BQ'
29
+ | 'BA'
30
+ | 'BW'
31
+ | 'BV'
32
+ | 'BR'
33
+ | 'IO'
34
+ | 'BN'
35
+ | 'BG'
36
+ | 'BF'
37
+ | 'BI'
38
+ | 'KH'
39
+ | 'CM'
40
+ | 'CA'
41
+ | 'CV'
42
+ | 'KY'
43
+ | 'CF'
44
+ | 'TD'
45
+ | 'CL'
46
+ | 'CN'
47
+ | 'CX'
48
+ | 'CC'
49
+ | 'CO'
50
+ | 'KM'
51
+ | 'CG'
52
+ | 'CD'
53
+ | 'CK'
54
+ | 'CR'
55
+ | 'HR'
56
+ | 'CU'
57
+ | 'CW'
58
+ | 'CY'
59
+ | 'CZ'
60
+ | 'CI'
61
+ | 'DK'
62
+ | 'DJ'
63
+ | 'DM'
64
+ | 'DO'
65
+ | 'EC'
66
+ | 'EG'
67
+ | 'SV'
68
+ | 'GQ'
69
+ | 'ER'
70
+ | 'EE'
71
+ | 'ET'
72
+ | 'FK'
73
+ | 'FO'
74
+ | 'FJ'
75
+ | 'FI'
76
+ | 'FR'
77
+ | 'GF'
78
+ | 'PF'
79
+ | 'TF'
80
+ | 'GA'
81
+ | 'GM'
82
+ | 'GE'
83
+ | 'DE'
84
+ | 'GH'
85
+ | 'GI'
86
+ | 'GR'
87
+ | 'GL'
88
+ | 'GD'
89
+ | 'GP'
90
+ | 'GU'
91
+ | 'GT'
92
+ | 'GG'
93
+ | 'GN'
94
+ | 'GW'
95
+ | 'GY'
96
+ | 'HT'
97
+ | 'HM'
98
+ | 'VA'
99
+ | 'HN'
100
+ | 'HK'
101
+ | 'HU'
102
+ | 'IS'
103
+ | 'IN'
104
+ | 'ID'
105
+ | 'IR'
106
+ | 'IQ'
107
+ | 'IE'
108
+ | 'IM'
109
+ | 'IL'
110
+ | 'IT'
111
+ | 'JM'
112
+ | 'JP'
113
+ | 'JE'
114
+ | 'JO'
115
+ | 'KZ'
116
+ | 'KE'
117
+ | 'KI'
118
+ | 'KP'
119
+ | 'KR'
120
+ | 'KW'
121
+ | 'KG'
122
+ | 'LA'
123
+ | 'LV'
124
+ | 'LB'
125
+ | 'LS'
126
+ | 'LR'
127
+ | 'LY'
128
+ | 'LI'
129
+ | 'LT'
130
+ | 'LU'
131
+ | 'MO'
132
+ | 'MK'
133
+ | 'MG'
134
+ | 'MW'
135
+ | 'MY'
136
+ | 'MV'
137
+ | 'ML'
138
+ | 'MT'
139
+ | 'MH'
140
+ | 'MQ'
141
+ | 'MR'
142
+ | 'MU'
143
+ | 'YT'
144
+ | 'MX'
145
+ | 'FM'
146
+ | 'MD'
147
+ | 'MC'
148
+ | 'MN'
149
+ | 'ME'
150
+ | 'MS'
151
+ | 'MA'
152
+ | 'MZ'
153
+ | 'MM'
154
+ | 'NA'
155
+ | 'NR'
156
+ | 'NP'
157
+ | 'NL'
158
+ | 'NC'
159
+ | 'NZ'
160
+ | 'NI'
161
+ | 'NE'
162
+ | 'NG'
163
+ | 'NU'
164
+ | 'NF'
165
+ | 'MP'
166
+ | 'NO'
167
+ | 'OM'
168
+ | 'PK'
169
+ | 'PW'
170
+ | 'PS'
171
+ | 'PA'
172
+ | 'PG'
173
+ | 'PY'
174
+ | 'PE'
175
+ | 'PH'
176
+ | 'PN'
177
+ | 'PL'
178
+ | 'PT'
179
+ | 'PR'
180
+ | 'QA'
181
+ | 'RO'
182
+ | 'RU'
183
+ | 'RW'
184
+ | 'RE'
185
+ | 'BL'
186
+ | 'SH'
187
+ | 'KN'
188
+ | 'LC'
189
+ | 'MF'
190
+ | 'PM'
191
+ | 'VC'
192
+ | 'WS'
193
+ | 'SM'
194
+ | 'ST'
195
+ | 'SA'
196
+ | 'SN'
197
+ | 'RS'
198
+ | 'SC'
199
+ | 'SL'
200
+ | 'SG'
201
+ | 'SX'
202
+ | 'SK'
203
+ | 'SI'
204
+ | 'SB'
205
+ | 'SO'
206
+ | 'ZA'
207
+ | 'GS'
208
+ | 'SS'
209
+ | 'ES'
210
+ | 'LK'
211
+ | 'SD'
212
+ | 'SR'
213
+ | 'SJ'
214
+ | 'SZ'
215
+ | 'SE'
216
+ | 'CH'
217
+ | 'SY'
218
+ | 'TW'
219
+ | 'TJ'
220
+ | 'TZ'
221
+ | 'TH'
222
+ | 'TL'
223
+ | 'TG'
224
+ | 'TK'
225
+ | 'TO'
226
+ | 'TT'
227
+ | 'TN'
228
+ | 'TR'
229
+ | 'TM'
230
+ | 'TC'
231
+ | 'TV'
232
+ | 'UG'
233
+ | 'UA'
234
+ | 'AE'
235
+ | 'GB'
236
+ | 'US'
237
+ | 'UM'
238
+ | 'UY'
239
+ | 'UZ'
240
+ | 'VU'
241
+ | 'VE'
242
+ | 'VN'
243
+ | 'VG'
244
+ | 'VI'
245
+ | 'WF'
246
+ | 'EH'
247
+ | 'YE'
248
+ | 'ZM'
249
+ | 'ZW'
250
+ | 'AX'
251
+
252
+ type Char =
253
+ | 'A'
254
+ | 'B'
255
+ | 'C'
256
+ | 'D'
257
+ | 'E'
258
+ | 'F'
259
+ | 'G'
260
+ | 'H'
261
+ | 'I'
262
+ | 'J'
263
+ | 'K'
264
+ | 'L'
265
+ | 'M'
266
+ | 'N'
267
+ | 'O'
268
+ | 'P'
269
+ | 'Q'
270
+ | 'R'
271
+ | 'S'
272
+ | 'T'
273
+ | 'U'
274
+ | 'V'
275
+ | 'W'
276
+ | 'X'
277
+ | 'Y'
278
+ | 'Z'
279
+ | '0'
280
+ | '1'
281
+ | '2'
282
+ | '3'
283
+ | '4'
284
+ | '5'
285
+ | '6'
286
+ | '7'
287
+ | '8'
288
+ | '9'
289
+
290
+ export type GeoRegionISO = `${Char}${Char}` | `${Char}${Char}${Char}`
291
+
292
+ export type Geo = {
293
+ country: CountryCode
294
+ /**
295
+ Ip formatted as ipv6
296
+
297
+ e.g. `2001:0db8:85a3:0000:0000:8a2e:0370:7334`
298
+ */
299
+ ip: string
300
+ /**
301
+ Region subdivisions
302
+
303
+ e.g. `[{ iso: 'NH', name: 'north-holland' }]`
304
+ */
305
+ regions: {
306
+ iso: GeoRegionISO
307
+ name?: string
308
+ }[]
309
+ lat: number
310
+ long: number
311
+ /**
312
+ Accuracy Radius (km)
313
+ */
314
+ accuracy: number
315
+ /**
316
+ City name
317
+
318
+ e.g. `Amsterdam`
319
+ */
320
+ city?: string
321
+ postalCode?: string
322
+ }
package/src/index.ts CHANGED
@@ -5,3 +5,4 @@ export * from './functions'
5
5
  export * from './query'
6
6
  export * from './stream'
7
7
  export * from './channel'
8
+ export * from './geo'