@thescaffold/jsx-flags 0.0.10

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/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # Scaffold
2
+
3
+ ## JSX Flags
4
+
5
+ ### Introduction
6
+
7
+ ### Supported Platforms
8
+
9
+ - Browser
10
+ - Node.js (Javascript/Typescript)
11
+
12
+ ### Installation
13
+
14
+ 1. NPM
15
+
16
+ ```bash
17
+ $ npm i @thescaffold/jsx-flags
18
+ ```
19
+
20
+ 2. CDN
21
+
22
+ ```html
23
+
24
+ ```
25
+
26
+ ### Usage & API
27
+
28
+ 1. Initialization
29
+
30
+ ```ts
31
+ import { init } from '@thescaffold/jsx-flags';
32
+
33
+ init({
34
+ // config
35
+ });
36
+ ```
37
+
38
+ 2. Events
39
+
40
+ - identify
41
+
42
+ ```ts
43
+ import { events } from '@thescaffold/jsx-flags';
44
+
45
+ events.identify(id, payload, options);
46
+ ```
47
+
48
+ - track
49
+
50
+ ```ts
51
+ import { events } from '@thescaffold/jsx-flags';
52
+
53
+ events.track(id, payload, options);
54
+ ```
55
+
56
+ 3. Jobs
57
+
58
+ - Schedule a new job
59
+
60
+ ```
61
+ import { jobs } from '@thescaffold/jsx-flags'
62
+
63
+ jobs.schedule(id, payload, options)
64
+ ```
65
+
66
+ 4. Files
67
+
68
+ - Upload file
69
+
70
+ ```
71
+ import { files } from '@thescaffold/jsx-flags'
72
+
73
+ files.upload(name, files, options)
74
+ ```
75
+
76
+ 5. Forms
77
+
78
+ - Submit form
79
+
80
+ ```
81
+ import { forms } from '@thescaffold/jsx-flags'
82
+
83
+ forms.submit(name, payload, options)
84
+ ```
85
+
86
+ 6. Webhooks
87
+
88
+ - register webhook
89
+
90
+ ```
91
+ import { webhooks } from '@thescaffold/jsx-flags'
92
+
93
+
94
+ webhooks.register(name, payload, options)
95
+ ```
96
+
97
+ 7. Logs
98
+
99
+ - identify
100
+
101
+ ```ts
102
+ import { events } from '@thescaffold/jsx-flags';
103
+
104
+ events.identify(id, payload, options);
105
+ ```
106
+
107
+ - track
108
+
109
+ ```ts
110
+ import { events } from '@thescaffold/jsx-flags';
111
+
112
+ events.track(id, payload, options);
113
+ ```
114
+
115
+ ## Commands
116
+
117
+ DTS scaffolds your new library inside `/src`.
118
+
119
+ To run DTS, use:
120
+
121
+ ```bash
122
+ npm start # or yarn start
123
+ ```
124
+
125
+ This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
126
+
127
+ To do a one-off build, use `npm run build` or `yarn build`.
128
+
129
+ To run tests, use `npm test` or `yarn test`.
130
+
131
+ ## Custom Commands
132
+
133
+ ```
134
+ # build and sync locally
135
+ $ node ./build --env=dev --sync=true
136
+
137
+ # build and publish
138
+ $ node ./build --env=prod --sync=true --version=x.x.x
139
+ ```
140
+
141
+ ## Publish
142
+
143
+ ```
144
+ $ git tag <version e.g v0.0.0>
145
+ $ git push origin <version>
146
+ ```
147
+
148
+ ## License
@@ -0,0 +1,2 @@
1
+ import { Config } from '../utils/values';
2
+ export declare const getConfig: () => Config;
@@ -0,0 +1,2 @@
1
+ import { Config } from '../utils/values';
2
+ export declare const init: (c: Config | any) => void;
@@ -0,0 +1,10 @@
1
+ import { Config, LogType } from './values';
2
+ export declare const isNode: () => boolean;
3
+ export declare const isBrowser: () => boolean;
4
+ export declare const isObject: (x: any) => boolean;
5
+ export declare const recursiveMerge: (target: any, ...sources: any[]) => any;
6
+ export declare const managedLog: (title: string, message: any, config: Config, ...types: LogType[]) => void;
7
+ export declare const sleep: (ms: number) => Promise<unknown>;
8
+ export declare const isFunction: (value: any) => boolean;
9
+ export declare const isString: (value: any) => boolean;
10
+ export declare const arrayDepth: (value: any) => number;
@@ -0,0 +1,77 @@
1
+ export type Data = Record<string, any>;
2
+ export declare enum CategoryType {
3
+ Form = "form",
4
+ File = "file",
5
+ Webhook = "webhook",
6
+ Job = "job",
7
+ Event = "event",
8
+ Log = "log",
9
+ Motion = "motion",
10
+ Message = "message",
11
+ Others = "others"
12
+ }
13
+ export declare enum LogType {
14
+ INFO = "info",
15
+ WARN = "warn",
16
+ ERROR = "error"
17
+ }
18
+ export interface Config {
19
+ /**
20
+ * Destination server base url
21
+ *
22
+ * Require
23
+ */
24
+ server: string;
25
+ /**
26
+ * Access token
27
+ */
28
+ credential: string;
29
+ /**
30
+ * SourceId
31
+ */
32
+ sourceId: string;
33
+ /**
34
+ * log display filter
35
+ */
36
+ logs?: LogType[];
37
+ debug?: boolean;
38
+ }
39
+ export interface BaseResponseBody {
40
+ status: 'success' | 'error' | string;
41
+ title: string;
42
+ message: string;
43
+ data?: any;
44
+ meta?: any;
45
+ raw?: string;
46
+ headers?: any;
47
+ [key: string]: any;
48
+ }
49
+ export interface BaseRequestBody {
50
+ [key: string]: any;
51
+ }
52
+ export interface BaseEntity {
53
+ id?: string;
54
+ createdAt?: string;
55
+ updateAt?: string;
56
+ deletedAt?: string;
57
+ [key: string]: any;
58
+ }
59
+ export interface BaseRequestQuery {
60
+ query?: string;
61
+ page?: number;
62
+ from?: string;
63
+ to?: string;
64
+ perPage?: number;
65
+ relations?: string;
66
+ columns?: string;
67
+ [key: string]: any;
68
+ }
69
+ export interface Flag {
70
+ name: string;
71
+ limit: number;
72
+ priority: number;
73
+ level: string;
74
+ reference?: string;
75
+ meta?: any;
76
+ status?: string;
77
+ }
@@ -0,0 +1,9 @@
1
+ import { Flag } from '../common/utils/values';
2
+ export declare const register: (flags: Flag[], environmentTypeName?: string) => Promise<boolean | null>;
3
+ export declare const log: (name: string, limit?: number, level?: string, userId?: string, clientId?: string, workspaceId?: string) => Promise<boolean | null>;
4
+ export declare const status: (names: any, level?: string, userId?: string, clientId?: string, workspaceId?: string) => Promise<boolean | null>;
5
+ export declare const limit: (name: string, level?: string, userId?: string, clientId?: string, workspaceId?: string) => Promise<{
6
+ allowed: boolean;
7
+ limit: number;
8
+ usage: number;
9
+ } | null>;
package/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { limit, log, register, status } from './flag/index';
2
+ /**
3
+ * Public APIs
4
+ */
5
+ export { init } from './common/init/index';
6
+ export * from './common/utils/values';
7
+ export * from './request/index';
8
+ export { limit, log, register, status };
package/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./jsx-flags.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./jsx-flags.cjs.development.js')
8
+ }