@walkeros/server-destination-api 0.0.0-next-20251219153324
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 +158 -0
- package/dist/dev.d.mts +104 -0
- package/dist/dev.d.ts +104 -0
- package/dist/dev.js +1 -0
- package/dist/dev.js.map +1 -0
- package/dist/dev.mjs +1 -0
- package/dist/dev.mjs.map +1 -0
- package/dist/examples/index.d.mts +77 -0
- package/dist/examples/index.d.ts +77 -0
- package/dist/examples/index.js +107 -0
- package/dist/examples/index.mjs +83 -0
- package/dist/index.d.mts +114 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<p align="left">
|
|
2
|
+
<a href="https://www.walkeros.io">
|
|
3
|
+
<img title="elbwalker" src="https://www.walkeros.io/img/elbwalker_logo.png" width="256px"/>
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# API Destination for walkerOS
|
|
8
|
+
|
|
9
|
+
[Source Code](https://github.com/elbwalker/walkerOS/tree/main/packages/server/destinations/api)
|
|
10
|
+
•
|
|
11
|
+
[NPM Package](https://www.npmjs.com/package/@walkeros/server-destination-api)
|
|
12
|
+
|
|
13
|
+
walkerOS follows a **source → collector → destination** architecture. This API
|
|
14
|
+
destination receives processed events from the walkerOS collector and sends them
|
|
15
|
+
to any HTTP(S) endpoint, enabling integration with custom APIs, webhooks, and
|
|
16
|
+
third-party services.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install @walkeros/server-destination-api
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
Configure in your Flow JSON:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"version": 1,
|
|
31
|
+
"flows": {
|
|
32
|
+
"default": {
|
|
33
|
+
"server": {},
|
|
34
|
+
"destinations": {
|
|
35
|
+
"api": {
|
|
36
|
+
"package": "@walkeros/server-destination-api",
|
|
37
|
+
"config": {
|
|
38
|
+
"settings": {
|
|
39
|
+
"url": "https://api.example.com/events"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Or programmatically:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { startFlow } from '@walkeros/collector';
|
|
53
|
+
import { destinationAPI } from '@walkeros/server-destination-api';
|
|
54
|
+
|
|
55
|
+
const { elb } = await startFlow({
|
|
56
|
+
destinations: [
|
|
57
|
+
{
|
|
58
|
+
destination: destinationAPI,
|
|
59
|
+
config: {
|
|
60
|
+
settings: {
|
|
61
|
+
url: 'https://api.example.com/events',
|
|
62
|
+
headers: {
|
|
63
|
+
Authorization: 'Bearer your-api-key',
|
|
64
|
+
'Content-Type': 'application/json',
|
|
65
|
+
},
|
|
66
|
+
method: 'POST',
|
|
67
|
+
timeout: 5000,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Configuration
|
|
76
|
+
|
|
77
|
+
| Name | Type | Description | Required | Default |
|
|
78
|
+
| ----------- | ------------------------ | ----------------------------------- | -------- | ------- |
|
|
79
|
+
| `url` | `string` | The API endpoint URL to send events | Yes | - |
|
|
80
|
+
| `headers` | `Record<string, string>` | Custom HTTP headers | No | - |
|
|
81
|
+
| `method` | `string` | HTTP method | No | `POST` |
|
|
82
|
+
| `timeout` | `number` | Request timeout in milliseconds | No | `5000` |
|
|
83
|
+
| `transform` | `Function` | Custom data transformation function | No | - |
|
|
84
|
+
|
|
85
|
+
## Features
|
|
86
|
+
|
|
87
|
+
- **Flexible URL Configuration**: Send events to any HTTP(S) endpoint
|
|
88
|
+
- **Custom Headers**: Add authentication tokens, API keys, or custom headers
|
|
89
|
+
- **HTTP Method Control**: Use POST, PUT, PATCH, or any HTTP method
|
|
90
|
+
- **Request Timeout**: Configure timeout for slow endpoints
|
|
91
|
+
- **Data Transformation**: Transform event data before sending with custom
|
|
92
|
+
functions
|
|
93
|
+
- **Dependency Injection**: Mock the sendServer function for testing
|
|
94
|
+
|
|
95
|
+
## Advanced Usage
|
|
96
|
+
|
|
97
|
+
### Custom Transform Function
|
|
98
|
+
|
|
99
|
+
Transform event data before sending:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { destinationAPI } from '@walkeros/server-destination-api';
|
|
103
|
+
|
|
104
|
+
const config = {
|
|
105
|
+
settings: {
|
|
106
|
+
url: 'https://api.example.com/events',
|
|
107
|
+
transform: (data, config, mapping) => {
|
|
108
|
+
// Return custom body (string or object)
|
|
109
|
+
return JSON.stringify({
|
|
110
|
+
eventType: data.event,
|
|
111
|
+
properties: data.data,
|
|
112
|
+
timestamp: Date.now(),
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Using with Mapping
|
|
120
|
+
|
|
121
|
+
Use walkerOS mapping to transform events:
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
const config = {
|
|
125
|
+
settings: { url: 'https://api.example.com/events' },
|
|
126
|
+
mapping: {
|
|
127
|
+
page: {
|
|
128
|
+
view: {
|
|
129
|
+
data: {
|
|
130
|
+
map: {
|
|
131
|
+
pageUrl: 'data.path',
|
|
132
|
+
pageTitle: 'data.title',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Type Definitions
|
|
142
|
+
|
|
143
|
+
See [src/types/](./src/types/) for TypeScript interfaces.
|
|
144
|
+
|
|
145
|
+
## Related
|
|
146
|
+
|
|
147
|
+
- [Destination Interface](../../../core/src/types/destination.ts)
|
|
148
|
+
|
|
149
|
+
## Contribute
|
|
150
|
+
|
|
151
|
+
Feel free to contribute by submitting an
|
|
152
|
+
[issue](https://github.com/elbwalker/walkerOS/issues), starting a
|
|
153
|
+
[discussion](https://github.com/elbwalker/walkerOS/discussions), or getting in
|
|
154
|
+
[contact](https://calendly.com/elb-alexander/30min).
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
This project is licensed under the MIT License.
|
package/dist/dev.d.mts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
2
|
+
import { z } from '@walkeros/core/dev';
|
|
3
|
+
import { Mapping as Mapping$1 } from '@walkeros/core';
|
|
4
|
+
import { DestinationServer, sendServer } from '@walkeros/server-core';
|
|
5
|
+
|
|
6
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
7
|
+
url: z.ZodString;
|
|
8
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
9
|
+
method: z.ZodOptional<z.ZodString>;
|
|
10
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
type Settings = z.infer<typeof SettingsSchema>;
|
|
13
|
+
|
|
14
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
15
|
+
|
|
16
|
+
type index$1_Settings = Settings;
|
|
17
|
+
declare const index$1_SettingsSchema: typeof SettingsSchema;
|
|
18
|
+
declare const index$1_settings: typeof settings;
|
|
19
|
+
declare namespace index$1 {
|
|
20
|
+
export { type index$1_Settings as Settings, index$1_SettingsSchema as SettingsSchema, index$1_settings as settings };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface Mapping {
|
|
24
|
+
}
|
|
25
|
+
interface Env extends DestinationServer.Env {
|
|
26
|
+
sendServer?: typeof sendServer;
|
|
27
|
+
}
|
|
28
|
+
type Rule = Mapping$1.Rule<Mapping>;
|
|
29
|
+
|
|
30
|
+
declare const init: Env | undefined;
|
|
31
|
+
declare const standard: Env;
|
|
32
|
+
|
|
33
|
+
declare const env_init: typeof init;
|
|
34
|
+
declare const env_standard: typeof standard;
|
|
35
|
+
declare namespace env {
|
|
36
|
+
export { env_init as init, env_standard as standard };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare function entity_action$1(): string;
|
|
40
|
+
|
|
41
|
+
declare namespace events {
|
|
42
|
+
export { entity_action$1 as entity_action };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare const entity_action: Rule;
|
|
46
|
+
declare const config: {
|
|
47
|
+
entity: {
|
|
48
|
+
action: Rule;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
declare const mapping_config: typeof config;
|
|
53
|
+
declare const mapping_entity_action: typeof entity_action;
|
|
54
|
+
declare namespace mapping {
|
|
55
|
+
export { mapping_config as config, mapping_entity_action as entity_action };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare const fullEventPost: {
|
|
59
|
+
url: string;
|
|
60
|
+
body: string;
|
|
61
|
+
options: {
|
|
62
|
+
headers: undefined;
|
|
63
|
+
method: undefined;
|
|
64
|
+
timeout: undefined;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
declare const mappedDataPost: {
|
|
68
|
+
url: string;
|
|
69
|
+
body: string;
|
|
70
|
+
options: {
|
|
71
|
+
headers: undefined;
|
|
72
|
+
method: undefined;
|
|
73
|
+
timeout: undefined;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
declare const customOptionsPost: {
|
|
77
|
+
url: string;
|
|
78
|
+
body: string;
|
|
79
|
+
options: {
|
|
80
|
+
headers: {
|
|
81
|
+
'X-API-Key': string;
|
|
82
|
+
'Content-Type': string;
|
|
83
|
+
};
|
|
84
|
+
method: string;
|
|
85
|
+
timeout: number;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
declare const outputs_customOptionsPost: typeof customOptionsPost;
|
|
90
|
+
declare const outputs_fullEventPost: typeof fullEventPost;
|
|
91
|
+
declare const outputs_mappedDataPost: typeof mappedDataPost;
|
|
92
|
+
declare namespace outputs {
|
|
93
|
+
export { outputs_customOptionsPost as customOptionsPost, outputs_fullEventPost as fullEventPost, outputs_mappedDataPost as mappedDataPost };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare const index_env: typeof env;
|
|
97
|
+
declare const index_events: typeof events;
|
|
98
|
+
declare const index_mapping: typeof mapping;
|
|
99
|
+
declare const index_outputs: typeof outputs;
|
|
100
|
+
declare namespace index {
|
|
101
|
+
export { index_env as env, index_events as events, index_mapping as mapping, index_outputs as outputs };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { index as examples, index$1 as schemas };
|
package/dist/dev.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
2
|
+
import { z } from '@walkeros/core/dev';
|
|
3
|
+
import { Mapping as Mapping$1 } from '@walkeros/core';
|
|
4
|
+
import { DestinationServer, sendServer } from '@walkeros/server-core';
|
|
5
|
+
|
|
6
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
7
|
+
url: z.ZodString;
|
|
8
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
9
|
+
method: z.ZodOptional<z.ZodString>;
|
|
10
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
type Settings = z.infer<typeof SettingsSchema>;
|
|
13
|
+
|
|
14
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
15
|
+
|
|
16
|
+
type index$1_Settings = Settings;
|
|
17
|
+
declare const index$1_SettingsSchema: typeof SettingsSchema;
|
|
18
|
+
declare const index$1_settings: typeof settings;
|
|
19
|
+
declare namespace index$1 {
|
|
20
|
+
export { type index$1_Settings as Settings, index$1_SettingsSchema as SettingsSchema, index$1_settings as settings };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface Mapping {
|
|
24
|
+
}
|
|
25
|
+
interface Env extends DestinationServer.Env {
|
|
26
|
+
sendServer?: typeof sendServer;
|
|
27
|
+
}
|
|
28
|
+
type Rule = Mapping$1.Rule<Mapping>;
|
|
29
|
+
|
|
30
|
+
declare const init: Env | undefined;
|
|
31
|
+
declare const standard: Env;
|
|
32
|
+
|
|
33
|
+
declare const env_init: typeof init;
|
|
34
|
+
declare const env_standard: typeof standard;
|
|
35
|
+
declare namespace env {
|
|
36
|
+
export { env_init as init, env_standard as standard };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare function entity_action$1(): string;
|
|
40
|
+
|
|
41
|
+
declare namespace events {
|
|
42
|
+
export { entity_action$1 as entity_action };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare const entity_action: Rule;
|
|
46
|
+
declare const config: {
|
|
47
|
+
entity: {
|
|
48
|
+
action: Rule;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
declare const mapping_config: typeof config;
|
|
53
|
+
declare const mapping_entity_action: typeof entity_action;
|
|
54
|
+
declare namespace mapping {
|
|
55
|
+
export { mapping_config as config, mapping_entity_action as entity_action };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare const fullEventPost: {
|
|
59
|
+
url: string;
|
|
60
|
+
body: string;
|
|
61
|
+
options: {
|
|
62
|
+
headers: undefined;
|
|
63
|
+
method: undefined;
|
|
64
|
+
timeout: undefined;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
declare const mappedDataPost: {
|
|
68
|
+
url: string;
|
|
69
|
+
body: string;
|
|
70
|
+
options: {
|
|
71
|
+
headers: undefined;
|
|
72
|
+
method: undefined;
|
|
73
|
+
timeout: undefined;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
declare const customOptionsPost: {
|
|
77
|
+
url: string;
|
|
78
|
+
body: string;
|
|
79
|
+
options: {
|
|
80
|
+
headers: {
|
|
81
|
+
'X-API-Key': string;
|
|
82
|
+
'Content-Type': string;
|
|
83
|
+
};
|
|
84
|
+
method: string;
|
|
85
|
+
timeout: number;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
declare const outputs_customOptionsPost: typeof customOptionsPost;
|
|
90
|
+
declare const outputs_fullEventPost: typeof fullEventPost;
|
|
91
|
+
declare const outputs_mappedDataPost: typeof mappedDataPost;
|
|
92
|
+
declare namespace outputs {
|
|
93
|
+
export { outputs_customOptionsPost as customOptionsPost, outputs_fullEventPost as fullEventPost, outputs_mappedDataPost as mappedDataPost };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare const index_env: typeof env;
|
|
97
|
+
declare const index_events: typeof events;
|
|
98
|
+
declare const index_mapping: typeof mapping;
|
|
99
|
+
declare const index_outputs: typeof outputs;
|
|
100
|
+
declare namespace index {
|
|
101
|
+
export { index_env as env, index_events as events, index_mapping as mapping, index_outputs as outputs };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { index as examples, index$1 as schemas };
|
package/dist/dev.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,n=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},s={};n(s,{examples:()=>l,schemas:()=>a}),module.exports=(e=s,((e,n,s,a)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let d of r(n))i.call(e,d)||d===s||t(e,d,{get:()=>n[d],enumerable:!(a=o(n,d))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={};n(a,{SettingsSchema:()=>p,settings:()=>u});var d=require("@walkeros/core/dev"),c=require("@walkeros/core/dev"),p=c.z.object({url:c.z.string().url().describe("The API endpoint URL to send events to"),headers:c.z.record(c.z.string(),c.z.string()).describe("Custom HTTP headers to include with requests").optional(),method:c.z.string().describe("HTTP method to use (default: POST)").optional(),timeout:c.z.number().positive().describe("Request timeout in milliseconds (default: 5000)").optional()}),u=(0,d.zodToSchema)(p),l={};n(l,{env:()=>v,events:()=>g,mapping:()=>f,outputs:()=>S});var v={};n(v,{init:()=>m,standard:()=>y});var m={sendServer:void 0},y={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},g={};n(g,{entity_action:()=>b});var h=require("@walkeros/core");function b(){const e=(0,h.getEvent)("entity action");return JSON.stringify(e.data)}var f={};n(f,{config:()=>P,entity_action:()=>O});var O={data:"data"},P={entity:{action:O}},S={};n(S,{customOptionsPost:()=>z,fullEventPost:()=>j,mappedDataPost:()=>w});var T=(0,require("@walkeros/core").getEvent)("entity action"),j={url:"https://api.example.com/events",body:JSON.stringify(T),options:{headers:void 0,method:void 0,timeout:void 0}},w={url:"https://api.example.com/events",body:JSON.stringify(T.data),options:{headers:void 0,method:void 0,timeout:void 0}},z={url:"https://api.example.com/events",body:JSON.stringify(T),options:{headers:{"X-API-Key":"YOUR_API_KEY","Content-Type":"application/json"},method:"PUT",timeout:1e4}};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/events.ts","../src/examples/mapping.ts","../src/examples/outputs.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n url: z.string().url().describe('The API endpoint URL to send events to'),\n headers: z\n .record(z.string(), z.string())\n .describe('Custom HTTP headers to include with requests')\n .optional(),\n method: z.string().describe('HTTP method to use (default: POST)').optional(),\n timeout: z\n .number()\n .positive()\n .describe('Request timeout in milliseconds (default: 5000)')\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","export * as env from './env';\nexport * as events from './events';\nexport * as mapping from './mapping';\nexport * as outputs from './outputs';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nconst noop = () => Promise.resolve({ ok: true });\n\nexport const init: Env | undefined = {\n sendServer: undefined,\n};\n\nexport const standard: Env = {\n sendServer: Object.assign(noop, {\n // Add any specific properties if needed for sendServer\n }) as unknown as Env['sendServer'],\n};\n","import { getEvent } from '@walkeros/core';\n\nexport function entity_action() {\n const event = getEvent('entity action');\n\n return JSON.stringify(event.data);\n}\n","import type { Mapping } from '@walkeros/core';\nimport type { Rule, Rules } from '../types';\n\nexport const entity_action: Rule = {\n data: 'data',\n};\n\nexport const config = {\n entity: { action: entity_action },\n} satisfies Rules;\n","import { getEvent } from '@walkeros/core';\n\n/**\n * Examples of API calls the destination will make.\n * Tests verify implementation produces these outputs.\n */\n\nconst sampleEvent = getEvent('entity action');\n\n// Full event POST (default behavior)\nexport const fullEventPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom data (via mapping)\nexport const mappedDataPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent.data),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom headers and method\nexport const customOptionsPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: {\n headers: {\n 'X-API-Key': 'YOUR_API_KEY',\n 'Content-Type': 'application/json',\n },\n method: 'PUT',\n timeout: 10000,\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACrC,KAAK,aAAE,OAAO,EAAE,IAAI,EAAE,SAAS,wCAAwC;AAAA,EACvE,SAAS,aACN,OAAO,aAAE,OAAO,GAAG,aAAE,OAAO,CAAC,EAC7B,SAAS,8CAA8C,EACvD,SAAS;AAAA,EACZ,QAAQ,aAAE,OAAO,EAAE,SAAS,oCAAoC,EAAE,SAAS;AAAA,EAC3E,SAAS,aACN,OAAO,EACP,SAAS,EACT,SAAS,iDAAiD,EAC1D,SAAS;AACd,CAAC;;;ADRM,IAAM,eAAW,yBAAY,cAAc;;;AENlD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,OAAO,MAAM,QAAQ,QAAQ,EAAE,IAAI,KAAK,CAAC;AAExC,IAAM,OAAwB;AAAA,EACnC,YAAY;AACd;AAEO,IAAM,WAAgB;AAAA,EAC3B,YAAY,OAAO,OAAO,MAAM;AAAA;AAAA,EAEhC,CAAC;AACH;;;ACnBA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AAElB,SAAS,gBAAgB;AAC9B,QAAM,YAAQ,sBAAS,eAAe;AAEtC,SAAO,KAAK,UAAU,MAAM,IAAI;AAClC;;;ACNA;AAAA;AAAA;AAAA,uBAAAC;AAAA;AAGO,IAAMA,iBAAsB;AAAA,EACjC,MAAM;AACR;AAEO,IAAM,SAAS;AAAA,EACpB,QAAQ,EAAE,QAAQA,eAAc;AAClC;;;ACTA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAC,eAAyB;AAOzB,IAAM,kBAAc,uBAAS,eAAe;AAGrC,IAAM,gBAAgB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,WAAW;AAAA,EAChC,SAAS,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AACvE;AAGO,IAAM,iBAAiB;AAAA,EAC5B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,YAAY,IAAI;AAAA,EACrC,SAAS,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AACvE;AAGO,IAAM,oBAAoB;AAAA,EAC/B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,WAAW;AAAA,EAChC,SAAS;AAAA,IACP,SAAS;AAAA,MACP,aAAa;AAAA,MACb,gBAAgB;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AACF;","names":["import_dev","entity_action","import_core"]}
|
package/dist/dev.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,o)=>{for(var i in o)e(t,i,{get:o[i],enumerable:!0})},o={};t(o,{SettingsSchema:()=>r,settings:()=>n});import{zodToSchema as i}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";var r=s.object({url:s.string().url().describe("The API endpoint URL to send events to"),headers:s.record(s.string(),s.string()).describe("Custom HTTP headers to include with requests").optional(),method:s.string().describe("HTTP method to use (default: POST)").optional(),timeout:s.number().positive().describe("Request timeout in milliseconds (default: 5000)").optional()}),n=i(r),a={};t(a,{env:()=>d,events:()=>c,mapping:()=>u,outputs:()=>g});var d={};t(d,{init:()=>m,standard:()=>p});var m={sendServer:void 0},p={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},c={};t(c,{entity_action:()=>l});import{getEvent as v}from"@walkeros/core";function l(){const e=v("entity action");return JSON.stringify(e.data)}var u={};t(u,{config:()=>f,entity_action:()=>h});var h={data:"data"},f={entity:{action:h}},g={};t(g,{customOptionsPost:()=>S,fullEventPost:()=>P,mappedDataPost:()=>O});import{getEvent as y}from"@walkeros/core";var b=y("entity action"),P={url:"https://api.example.com/events",body:JSON.stringify(b),options:{headers:void 0,method:void 0,timeout:void 0}},O={url:"https://api.example.com/events",body:JSON.stringify(b.data),options:{headers:void 0,method:void 0,timeout:void 0}},S={url:"https://api.example.com/events",body:JSON.stringify(b),options:{headers:{"X-API-Key":"YOUR_API_KEY","Content-Type":"application/json"},method:"PUT",timeout:1e4}};export{a as examples,o as schemas};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/events.ts","../src/examples/mapping.ts","../src/examples/outputs.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n url: z.string().url().describe('The API endpoint URL to send events to'),\n headers: z\n .record(z.string(), z.string())\n .describe('Custom HTTP headers to include with requests')\n .optional(),\n method: z.string().describe('HTTP method to use (default: POST)').optional(),\n timeout: z\n .number()\n .positive()\n .describe('Request timeout in milliseconds (default: 5000)')\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","export * as env from './env';\nexport * as events from './events';\nexport * as mapping from './mapping';\nexport * as outputs from './outputs';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nconst noop = () => Promise.resolve({ ok: true });\n\nexport const init: Env | undefined = {\n sendServer: undefined,\n};\n\nexport const standard: Env = {\n sendServer: Object.assign(noop, {\n // Add any specific properties if needed for sendServer\n }) as unknown as Env['sendServer'],\n};\n","import { getEvent } from '@walkeros/core';\n\nexport function entity_action() {\n const event = getEvent('entity action');\n\n return JSON.stringify(event.data);\n}\n","import type { Mapping } from '@walkeros/core';\nimport type { Rule, Rules } from '../types';\n\nexport const entity_action: Rule = {\n data: 'data',\n};\n\nexport const config = {\n entity: { action: entity_action },\n} satisfies Rules;\n","import { getEvent } from '@walkeros/core';\n\n/**\n * Examples of API calls the destination will make.\n * Tests verify implementation produces these outputs.\n */\n\nconst sampleEvent = getEvent('entity action');\n\n// Full event POST (default behavior)\nexport const fullEventPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom data (via mapping)\nexport const mappedDataPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent.data),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom headers and method\nexport const customOptionsPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: {\n headers: {\n 'X-API-Key': 'YOUR_API_KEY',\n 'Content-Type': 'application/json',\n },\n method: 'PUT',\n timeout: 10000,\n },\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,wCAAwC;AAAA,EACvE,SAAS,EACN,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAC7B,SAAS,8CAA8C,EACvD,SAAS;AAAA,EACZ,QAAQ,EAAE,OAAO,EAAE,SAAS,oCAAoC,EAAE,SAAS;AAAA,EAC3E,SAAS,EACN,OAAO,EACP,SAAS,EACT,SAAS,iDAAiD,EAC1D,SAAS;AACd,CAAC;;;ADRM,IAAM,WAAW,YAAY,cAAc;;;AENlD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,OAAO,MAAM,QAAQ,QAAQ,EAAE,IAAI,KAAK,CAAC;AAExC,IAAM,OAAwB;AAAA,EACnC,YAAY;AACd;AAEO,IAAM,WAAgB;AAAA,EAC3B,YAAY,OAAO,OAAO,MAAM;AAAA;AAAA,EAEhC,CAAC;AACH;;;ACnBA;AAAA;AAAA;AAAA;AAAA,SAAS,gBAAgB;AAElB,SAAS,gBAAgB;AAC9B,QAAM,QAAQ,SAAS,eAAe;AAEtC,SAAO,KAAK,UAAU,MAAM,IAAI;AAClC;;;ACNA;AAAA;AAAA;AAAA,uBAAAA;AAAA;AAGO,IAAMA,iBAAsB;AAAA,EACjC,MAAM;AACR;AAEO,IAAM,SAAS;AAAA,EACpB,QAAQ,EAAE,QAAQA,eAAc;AAClC;;;ACTA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,YAAAC,iBAAgB;AAOzB,IAAM,cAAcA,UAAS,eAAe;AAGrC,IAAM,gBAAgB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,WAAW;AAAA,EAChC,SAAS,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AACvE;AAGO,IAAM,iBAAiB;AAAA,EAC5B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,YAAY,IAAI;AAAA,EACrC,SAAS,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AACvE;AAGO,IAAM,oBAAoB;AAAA,EAC/B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,WAAW;AAAA,EAChC,SAAS;AAAA,IACP,SAAS;AAAA,MACP,aAAa;AAAA,MACb,gBAAgB;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AACF;","names":["entity_action","getEvent"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Mapping as Mapping$1 } from '@walkeros/core';
|
|
2
|
+
import { DestinationServer, sendServer } from '@walkeros/server-core';
|
|
3
|
+
|
|
4
|
+
interface Mapping {
|
|
5
|
+
}
|
|
6
|
+
interface Env extends DestinationServer.Env {
|
|
7
|
+
sendServer?: typeof sendServer;
|
|
8
|
+
}
|
|
9
|
+
type Rule = Mapping$1.Rule<Mapping>;
|
|
10
|
+
|
|
11
|
+
declare const init: Env | undefined;
|
|
12
|
+
declare const standard: Env;
|
|
13
|
+
|
|
14
|
+
declare const env_init: typeof init;
|
|
15
|
+
declare const env_standard: typeof standard;
|
|
16
|
+
declare namespace env {
|
|
17
|
+
export { env_init as init, env_standard as standard };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare function entity_action$1(): string;
|
|
21
|
+
|
|
22
|
+
declare namespace events {
|
|
23
|
+
export { entity_action$1 as entity_action };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare const entity_action: Rule;
|
|
27
|
+
declare const config: {
|
|
28
|
+
entity: {
|
|
29
|
+
action: Rule;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
declare const mapping_config: typeof config;
|
|
34
|
+
declare const mapping_entity_action: typeof entity_action;
|
|
35
|
+
declare namespace mapping {
|
|
36
|
+
export { mapping_config as config, mapping_entity_action as entity_action };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare const fullEventPost: {
|
|
40
|
+
url: string;
|
|
41
|
+
body: string;
|
|
42
|
+
options: {
|
|
43
|
+
headers: undefined;
|
|
44
|
+
method: undefined;
|
|
45
|
+
timeout: undefined;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
declare const mappedDataPost: {
|
|
49
|
+
url: string;
|
|
50
|
+
body: string;
|
|
51
|
+
options: {
|
|
52
|
+
headers: undefined;
|
|
53
|
+
method: undefined;
|
|
54
|
+
timeout: undefined;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
declare const customOptionsPost: {
|
|
58
|
+
url: string;
|
|
59
|
+
body: string;
|
|
60
|
+
options: {
|
|
61
|
+
headers: {
|
|
62
|
+
'X-API-Key': string;
|
|
63
|
+
'Content-Type': string;
|
|
64
|
+
};
|
|
65
|
+
method: string;
|
|
66
|
+
timeout: number;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
declare const outputs_customOptionsPost: typeof customOptionsPost;
|
|
71
|
+
declare const outputs_fullEventPost: typeof fullEventPost;
|
|
72
|
+
declare const outputs_mappedDataPost: typeof mappedDataPost;
|
|
73
|
+
declare namespace outputs {
|
|
74
|
+
export { outputs_customOptionsPost as customOptionsPost, outputs_fullEventPost as fullEventPost, outputs_mappedDataPost as mappedDataPost };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { env, events, mapping, outputs };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Mapping as Mapping$1 } from '@walkeros/core';
|
|
2
|
+
import { DestinationServer, sendServer } from '@walkeros/server-core';
|
|
3
|
+
|
|
4
|
+
interface Mapping {
|
|
5
|
+
}
|
|
6
|
+
interface Env extends DestinationServer.Env {
|
|
7
|
+
sendServer?: typeof sendServer;
|
|
8
|
+
}
|
|
9
|
+
type Rule = Mapping$1.Rule<Mapping>;
|
|
10
|
+
|
|
11
|
+
declare const init: Env | undefined;
|
|
12
|
+
declare const standard: Env;
|
|
13
|
+
|
|
14
|
+
declare const env_init: typeof init;
|
|
15
|
+
declare const env_standard: typeof standard;
|
|
16
|
+
declare namespace env {
|
|
17
|
+
export { env_init as init, env_standard as standard };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare function entity_action$1(): string;
|
|
21
|
+
|
|
22
|
+
declare namespace events {
|
|
23
|
+
export { entity_action$1 as entity_action };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare const entity_action: Rule;
|
|
27
|
+
declare const config: {
|
|
28
|
+
entity: {
|
|
29
|
+
action: Rule;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
declare const mapping_config: typeof config;
|
|
34
|
+
declare const mapping_entity_action: typeof entity_action;
|
|
35
|
+
declare namespace mapping {
|
|
36
|
+
export { mapping_config as config, mapping_entity_action as entity_action };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare const fullEventPost: {
|
|
40
|
+
url: string;
|
|
41
|
+
body: string;
|
|
42
|
+
options: {
|
|
43
|
+
headers: undefined;
|
|
44
|
+
method: undefined;
|
|
45
|
+
timeout: undefined;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
declare const mappedDataPost: {
|
|
49
|
+
url: string;
|
|
50
|
+
body: string;
|
|
51
|
+
options: {
|
|
52
|
+
headers: undefined;
|
|
53
|
+
method: undefined;
|
|
54
|
+
timeout: undefined;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
declare const customOptionsPost: {
|
|
58
|
+
url: string;
|
|
59
|
+
body: string;
|
|
60
|
+
options: {
|
|
61
|
+
headers: {
|
|
62
|
+
'X-API-Key': string;
|
|
63
|
+
'Content-Type': string;
|
|
64
|
+
};
|
|
65
|
+
method: string;
|
|
66
|
+
timeout: number;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
declare const outputs_customOptionsPost: typeof customOptionsPost;
|
|
71
|
+
declare const outputs_fullEventPost: typeof fullEventPost;
|
|
72
|
+
declare const outputs_mappedDataPost: typeof mappedDataPost;
|
|
73
|
+
declare namespace outputs {
|
|
74
|
+
export { outputs_customOptionsPost as customOptionsPost, outputs_fullEventPost as fullEventPost, outputs_mappedDataPost as mappedDataPost };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { env, events, mapping, outputs };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/examples/index.ts
|
|
21
|
+
var examples_exports = {};
|
|
22
|
+
__export(examples_exports, {
|
|
23
|
+
env: () => env_exports,
|
|
24
|
+
events: () => events_exports,
|
|
25
|
+
mapping: () => mapping_exports,
|
|
26
|
+
outputs: () => outputs_exports
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(examples_exports);
|
|
29
|
+
|
|
30
|
+
// src/examples/env.ts
|
|
31
|
+
var env_exports = {};
|
|
32
|
+
__export(env_exports, {
|
|
33
|
+
init: () => init,
|
|
34
|
+
standard: () => standard
|
|
35
|
+
});
|
|
36
|
+
var noop = () => Promise.resolve({ ok: true });
|
|
37
|
+
var init = {
|
|
38
|
+
sendServer: void 0
|
|
39
|
+
};
|
|
40
|
+
var standard = {
|
|
41
|
+
sendServer: Object.assign(noop, {
|
|
42
|
+
// Add any specific properties if needed for sendServer
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/examples/events.ts
|
|
47
|
+
var events_exports = {};
|
|
48
|
+
__export(events_exports, {
|
|
49
|
+
entity_action: () => entity_action
|
|
50
|
+
});
|
|
51
|
+
var import_core = require("@walkeros/core");
|
|
52
|
+
function entity_action() {
|
|
53
|
+
const event = (0, import_core.getEvent)("entity action");
|
|
54
|
+
return JSON.stringify(event.data);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/examples/mapping.ts
|
|
58
|
+
var mapping_exports = {};
|
|
59
|
+
__export(mapping_exports, {
|
|
60
|
+
config: () => config,
|
|
61
|
+
entity_action: () => entity_action2
|
|
62
|
+
});
|
|
63
|
+
var entity_action2 = {
|
|
64
|
+
data: "data"
|
|
65
|
+
};
|
|
66
|
+
var config = {
|
|
67
|
+
entity: { action: entity_action2 }
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// src/examples/outputs.ts
|
|
71
|
+
var outputs_exports = {};
|
|
72
|
+
__export(outputs_exports, {
|
|
73
|
+
customOptionsPost: () => customOptionsPost,
|
|
74
|
+
fullEventPost: () => fullEventPost,
|
|
75
|
+
mappedDataPost: () => mappedDataPost
|
|
76
|
+
});
|
|
77
|
+
var import_core2 = require("@walkeros/core");
|
|
78
|
+
var sampleEvent = (0, import_core2.getEvent)("entity action");
|
|
79
|
+
var fullEventPost = {
|
|
80
|
+
url: "https://api.example.com/events",
|
|
81
|
+
body: JSON.stringify(sampleEvent),
|
|
82
|
+
options: { headers: void 0, method: void 0, timeout: void 0 }
|
|
83
|
+
};
|
|
84
|
+
var mappedDataPost = {
|
|
85
|
+
url: "https://api.example.com/events",
|
|
86
|
+
body: JSON.stringify(sampleEvent.data),
|
|
87
|
+
options: { headers: void 0, method: void 0, timeout: void 0 }
|
|
88
|
+
};
|
|
89
|
+
var customOptionsPost = {
|
|
90
|
+
url: "https://api.example.com/events",
|
|
91
|
+
body: JSON.stringify(sampleEvent),
|
|
92
|
+
options: {
|
|
93
|
+
headers: {
|
|
94
|
+
"X-API-Key": "YOUR_API_KEY",
|
|
95
|
+
"Content-Type": "application/json"
|
|
96
|
+
},
|
|
97
|
+
method: "PUT",
|
|
98
|
+
timeout: 1e4
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
env,
|
|
104
|
+
events,
|
|
105
|
+
mapping,
|
|
106
|
+
outputs
|
|
107
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/examples/env.ts
|
|
8
|
+
var env_exports = {};
|
|
9
|
+
__export(env_exports, {
|
|
10
|
+
init: () => init,
|
|
11
|
+
standard: () => standard
|
|
12
|
+
});
|
|
13
|
+
var noop = () => Promise.resolve({ ok: true });
|
|
14
|
+
var init = {
|
|
15
|
+
sendServer: void 0
|
|
16
|
+
};
|
|
17
|
+
var standard = {
|
|
18
|
+
sendServer: Object.assign(noop, {
|
|
19
|
+
// Add any specific properties if needed for sendServer
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// src/examples/events.ts
|
|
24
|
+
var events_exports = {};
|
|
25
|
+
__export(events_exports, {
|
|
26
|
+
entity_action: () => entity_action
|
|
27
|
+
});
|
|
28
|
+
import { getEvent } from "@walkeros/core";
|
|
29
|
+
function entity_action() {
|
|
30
|
+
const event = getEvent("entity action");
|
|
31
|
+
return JSON.stringify(event.data);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/examples/mapping.ts
|
|
35
|
+
var mapping_exports = {};
|
|
36
|
+
__export(mapping_exports, {
|
|
37
|
+
config: () => config,
|
|
38
|
+
entity_action: () => entity_action2
|
|
39
|
+
});
|
|
40
|
+
var entity_action2 = {
|
|
41
|
+
data: "data"
|
|
42
|
+
};
|
|
43
|
+
var config = {
|
|
44
|
+
entity: { action: entity_action2 }
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/examples/outputs.ts
|
|
48
|
+
var outputs_exports = {};
|
|
49
|
+
__export(outputs_exports, {
|
|
50
|
+
customOptionsPost: () => customOptionsPost,
|
|
51
|
+
fullEventPost: () => fullEventPost,
|
|
52
|
+
mappedDataPost: () => mappedDataPost
|
|
53
|
+
});
|
|
54
|
+
import { getEvent as getEvent2 } from "@walkeros/core";
|
|
55
|
+
var sampleEvent = getEvent2("entity action");
|
|
56
|
+
var fullEventPost = {
|
|
57
|
+
url: "https://api.example.com/events",
|
|
58
|
+
body: JSON.stringify(sampleEvent),
|
|
59
|
+
options: { headers: void 0, method: void 0, timeout: void 0 }
|
|
60
|
+
};
|
|
61
|
+
var mappedDataPost = {
|
|
62
|
+
url: "https://api.example.com/events",
|
|
63
|
+
body: JSON.stringify(sampleEvent.data),
|
|
64
|
+
options: { headers: void 0, method: void 0, timeout: void 0 }
|
|
65
|
+
};
|
|
66
|
+
var customOptionsPost = {
|
|
67
|
+
url: "https://api.example.com/events",
|
|
68
|
+
body: JSON.stringify(sampleEvent),
|
|
69
|
+
options: {
|
|
70
|
+
headers: {
|
|
71
|
+
"X-API-Key": "YOUR_API_KEY",
|
|
72
|
+
"Content-Type": "application/json"
|
|
73
|
+
},
|
|
74
|
+
method: "PUT",
|
|
75
|
+
timeout: 1e4
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
env_exports as env,
|
|
80
|
+
events_exports as events,
|
|
81
|
+
mapping_exports as mapping,
|
|
82
|
+
outputs_exports as outputs
|
|
83
|
+
};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Destination as Destination$1, SendHeaders, Mapping as Mapping$1, SendDataValue } from '@walkeros/core';
|
|
2
|
+
import { DestinationServer, sendServer } from '@walkeros/server-core';
|
|
3
|
+
|
|
4
|
+
interface Settings {
|
|
5
|
+
url: string;
|
|
6
|
+
headers?: SendHeaders;
|
|
7
|
+
method?: string;
|
|
8
|
+
transform?: Transform;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
interface Mapping {
|
|
12
|
+
}
|
|
13
|
+
interface Env extends DestinationServer.Env {
|
|
14
|
+
sendServer?: typeof sendServer;
|
|
15
|
+
}
|
|
16
|
+
type Types = Destination$1.Types<Settings, Mapping, Env>;
|
|
17
|
+
type Destination = DestinationServer.Destination<Types>;
|
|
18
|
+
type Config = DestinationServer.Config<Types>;
|
|
19
|
+
type PushFn = DestinationServer.PushFn<Types>;
|
|
20
|
+
type Rule = Mapping$1.Rule<Mapping>;
|
|
21
|
+
type Rules = Mapping$1.Rules<Rule>;
|
|
22
|
+
type Transform = (data?: unknown, config?: Config, mapping?: Mapping$1.Rule<Mapping>) => SendDataValue;
|
|
23
|
+
|
|
24
|
+
type index$1_Config = Config;
|
|
25
|
+
type index$1_Destination = Destination;
|
|
26
|
+
type index$1_Env = Env;
|
|
27
|
+
type index$1_Mapping = Mapping;
|
|
28
|
+
type index$1_PushFn = PushFn;
|
|
29
|
+
type index$1_Rule = Rule;
|
|
30
|
+
type index$1_Rules = Rules;
|
|
31
|
+
type index$1_Settings = Settings;
|
|
32
|
+
type index$1_Transform = Transform;
|
|
33
|
+
type index$1_Types = Types;
|
|
34
|
+
declare namespace index$1 {
|
|
35
|
+
export type { index$1_Config as Config, index$1_Destination as Destination, index$1_Env as Env, index$1_Mapping as Mapping, index$1_PushFn as PushFn, index$1_Rule as Rule, index$1_Rules as Rules, index$1_Settings as Settings, index$1_Transform as Transform, index$1_Types as Types };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare const init: Env | undefined;
|
|
39
|
+
declare const standard: Env;
|
|
40
|
+
|
|
41
|
+
declare const env_init: typeof init;
|
|
42
|
+
declare const env_standard: typeof standard;
|
|
43
|
+
declare namespace env {
|
|
44
|
+
export { env_init as init, env_standard as standard };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare function entity_action$1(): string;
|
|
48
|
+
|
|
49
|
+
declare namespace events {
|
|
50
|
+
export { entity_action$1 as entity_action };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare const entity_action: Rule;
|
|
54
|
+
declare const config: {
|
|
55
|
+
entity: {
|
|
56
|
+
action: Rule;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
declare const mapping_config: typeof config;
|
|
61
|
+
declare const mapping_entity_action: typeof entity_action;
|
|
62
|
+
declare namespace mapping {
|
|
63
|
+
export { mapping_config as config, mapping_entity_action as entity_action };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare const fullEventPost: {
|
|
67
|
+
url: string;
|
|
68
|
+
body: string;
|
|
69
|
+
options: {
|
|
70
|
+
headers: undefined;
|
|
71
|
+
method: undefined;
|
|
72
|
+
timeout: undefined;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
declare const mappedDataPost: {
|
|
76
|
+
url: string;
|
|
77
|
+
body: string;
|
|
78
|
+
options: {
|
|
79
|
+
headers: undefined;
|
|
80
|
+
method: undefined;
|
|
81
|
+
timeout: undefined;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
declare const customOptionsPost: {
|
|
85
|
+
url: string;
|
|
86
|
+
body: string;
|
|
87
|
+
options: {
|
|
88
|
+
headers: {
|
|
89
|
+
'X-API-Key': string;
|
|
90
|
+
'Content-Type': string;
|
|
91
|
+
};
|
|
92
|
+
method: string;
|
|
93
|
+
timeout: number;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
declare const outputs_customOptionsPost: typeof customOptionsPost;
|
|
98
|
+
declare const outputs_fullEventPost: typeof fullEventPost;
|
|
99
|
+
declare const outputs_mappedDataPost: typeof mappedDataPost;
|
|
100
|
+
declare namespace outputs {
|
|
101
|
+
export { outputs_customOptionsPost as customOptionsPost, outputs_fullEventPost as fullEventPost, outputs_mappedDataPost as mappedDataPost };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare const index_env: typeof env;
|
|
105
|
+
declare const index_events: typeof events;
|
|
106
|
+
declare const index_mapping: typeof mapping;
|
|
107
|
+
declare const index_outputs: typeof outputs;
|
|
108
|
+
declare namespace index {
|
|
109
|
+
export { index_env as env, index_events as events, index_mapping as mapping, index_outputs as outputs };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare const destinationAPI: Destination;
|
|
113
|
+
|
|
114
|
+
export { index$1 as DestinationAPI, destinationAPI as default, destinationAPI, index as examples };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Destination as Destination$1, SendHeaders, Mapping as Mapping$1, SendDataValue } from '@walkeros/core';
|
|
2
|
+
import { DestinationServer, sendServer } from '@walkeros/server-core';
|
|
3
|
+
|
|
4
|
+
interface Settings {
|
|
5
|
+
url: string;
|
|
6
|
+
headers?: SendHeaders;
|
|
7
|
+
method?: string;
|
|
8
|
+
transform?: Transform;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
interface Mapping {
|
|
12
|
+
}
|
|
13
|
+
interface Env extends DestinationServer.Env {
|
|
14
|
+
sendServer?: typeof sendServer;
|
|
15
|
+
}
|
|
16
|
+
type Types = Destination$1.Types<Settings, Mapping, Env>;
|
|
17
|
+
type Destination = DestinationServer.Destination<Types>;
|
|
18
|
+
type Config = DestinationServer.Config<Types>;
|
|
19
|
+
type PushFn = DestinationServer.PushFn<Types>;
|
|
20
|
+
type Rule = Mapping$1.Rule<Mapping>;
|
|
21
|
+
type Rules = Mapping$1.Rules<Rule>;
|
|
22
|
+
type Transform = (data?: unknown, config?: Config, mapping?: Mapping$1.Rule<Mapping>) => SendDataValue;
|
|
23
|
+
|
|
24
|
+
type index$1_Config = Config;
|
|
25
|
+
type index$1_Destination = Destination;
|
|
26
|
+
type index$1_Env = Env;
|
|
27
|
+
type index$1_Mapping = Mapping;
|
|
28
|
+
type index$1_PushFn = PushFn;
|
|
29
|
+
type index$1_Rule = Rule;
|
|
30
|
+
type index$1_Rules = Rules;
|
|
31
|
+
type index$1_Settings = Settings;
|
|
32
|
+
type index$1_Transform = Transform;
|
|
33
|
+
type index$1_Types = Types;
|
|
34
|
+
declare namespace index$1 {
|
|
35
|
+
export type { index$1_Config as Config, index$1_Destination as Destination, index$1_Env as Env, index$1_Mapping as Mapping, index$1_PushFn as PushFn, index$1_Rule as Rule, index$1_Rules as Rules, index$1_Settings as Settings, index$1_Transform as Transform, index$1_Types as Types };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare const init: Env | undefined;
|
|
39
|
+
declare const standard: Env;
|
|
40
|
+
|
|
41
|
+
declare const env_init: typeof init;
|
|
42
|
+
declare const env_standard: typeof standard;
|
|
43
|
+
declare namespace env {
|
|
44
|
+
export { env_init as init, env_standard as standard };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare function entity_action$1(): string;
|
|
48
|
+
|
|
49
|
+
declare namespace events {
|
|
50
|
+
export { entity_action$1 as entity_action };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare const entity_action: Rule;
|
|
54
|
+
declare const config: {
|
|
55
|
+
entity: {
|
|
56
|
+
action: Rule;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
declare const mapping_config: typeof config;
|
|
61
|
+
declare const mapping_entity_action: typeof entity_action;
|
|
62
|
+
declare namespace mapping {
|
|
63
|
+
export { mapping_config as config, mapping_entity_action as entity_action };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare const fullEventPost: {
|
|
67
|
+
url: string;
|
|
68
|
+
body: string;
|
|
69
|
+
options: {
|
|
70
|
+
headers: undefined;
|
|
71
|
+
method: undefined;
|
|
72
|
+
timeout: undefined;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
declare const mappedDataPost: {
|
|
76
|
+
url: string;
|
|
77
|
+
body: string;
|
|
78
|
+
options: {
|
|
79
|
+
headers: undefined;
|
|
80
|
+
method: undefined;
|
|
81
|
+
timeout: undefined;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
declare const customOptionsPost: {
|
|
85
|
+
url: string;
|
|
86
|
+
body: string;
|
|
87
|
+
options: {
|
|
88
|
+
headers: {
|
|
89
|
+
'X-API-Key': string;
|
|
90
|
+
'Content-Type': string;
|
|
91
|
+
};
|
|
92
|
+
method: string;
|
|
93
|
+
timeout: number;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
declare const outputs_customOptionsPost: typeof customOptionsPost;
|
|
98
|
+
declare const outputs_fullEventPost: typeof fullEventPost;
|
|
99
|
+
declare const outputs_mappedDataPost: typeof mappedDataPost;
|
|
100
|
+
declare namespace outputs {
|
|
101
|
+
export { outputs_customOptionsPost as customOptionsPost, outputs_fullEventPost as fullEventPost, outputs_mappedDataPost as mappedDataPost };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare const index_env: typeof env;
|
|
105
|
+
declare const index_events: typeof events;
|
|
106
|
+
declare const index_mapping: typeof mapping;
|
|
107
|
+
declare const index_outputs: typeof outputs;
|
|
108
|
+
declare namespace index {
|
|
109
|
+
export { index_env as env, index_events as events, index_mapping as mapping, index_outputs as outputs };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare const destinationAPI: Destination;
|
|
113
|
+
|
|
114
|
+
export { index$1 as DestinationAPI, destinationAPI as default, destinationAPI, index as examples };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},index_exports={};__export(index_exports,{DestinationAPI:()=>types_exports,default:()=>index_default,destinationAPI:()=>destinationAPI,examples:()=>examples_exports}),module.exports=(mod=index_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var import_core3=require("@walkeros/core"),import_server_core=require("@walkeros/server-core"),types_exports={},examples_exports={};__export(examples_exports,{env:()=>env_exports,events:()=>events_exports,mapping:()=>mapping_exports,outputs:()=>outputs_exports});var env_exports={};__export(env_exports,{init:()=>init,standard:()=>standard});var init={sendServer:void 0},standard={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},events_exports={};__export(events_exports,{entity_action:()=>entity_action});var import_core=require("@walkeros/core");function entity_action(){const event=(0,import_core.getEvent)("entity action");return JSON.stringify(event.data)}var mapping_exports={};__export(mapping_exports,{config:()=>config,entity_action:()=>entity_action2});var entity_action2={data:"data"},config={entity:{action:entity_action2}},outputs_exports={};__export(outputs_exports,{customOptionsPost:()=>customOptionsPost,fullEventPost:()=>fullEventPost,mappedDataPost:()=>mappedDataPost});var sampleEvent=(0,require("@walkeros/core").getEvent)("entity action"),fullEventPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent),options:{headers:void 0,method:void 0,timeout:void 0}},mappedDataPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent.data),options:{headers:void 0,method:void 0,timeout:void 0}},customOptionsPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent),options:{headers:{"X-API-Key":"YOUR_API_KEY","Content-Type":"application/json"},method:"PUT",timeout:1e4}},destinationAPI={type:"api",config:{},env:{sendServer:import_server_core.sendServer},async push(event,{config:config2,mapping:mapping,data:data,env:env,logger:logger}){const{settings:settings}=config2,{url:url,headers:headers,method:method,transform:transform,timeout:timeout}=settings||{};if(!url)return;const eventData=(0,import_core3.isDefined)(data)?data:event,body=transform?transform(eventData,config2,mapping):JSON.stringify(eventData);null==logger||logger.debug("API destination sending request",{url:url,method:method||"POST",eventName:event.name});const sendServerFn=(null==env?void 0:env.sendServer)||import_server_core.sendServer,response=await sendServerFn(url,body,{headers:headers,method:method,timeout:timeout});null==logger||logger.debug("API destination response",{ok:null==response?void 0:response.ok})}},index_default=destinationAPI;//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/events.ts","../src/examples/mapping.ts","../src/examples/outputs.ts"],"sourcesContent":["import type { Settings, Destination, Env } from './types';\nimport { isDefined } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\n\n// Types\nexport * as DestinationAPI from './types';\n\n// Examples\nexport * as examples from './examples';\n\nexport const destinationAPI: Destination = {\n type: 'api',\n\n config: {},\n\n env: { sendServer },\n\n async push(event, { config, mapping, data, env, logger }) {\n const { settings } = config;\n const { url, headers, method, transform, timeout } = settings || {};\n\n if (!url) return;\n\n const eventData = isDefined(data) ? data : event;\n const body = transform\n ? transform(eventData, config, mapping) // Transform event data\n : JSON.stringify(eventData);\n\n logger?.debug('API destination sending request', {\n url,\n method: method || 'POST',\n eventName: event.name,\n });\n\n const sendServerFn = (env as Env)?.sendServer || sendServer;\n const response = await sendServerFn(url, body, {\n headers,\n method,\n timeout,\n });\n\n logger?.debug('API destination response', { ok: response?.ok });\n },\n};\n\nexport default destinationAPI;\n","import type {\n Mapping as WalkerOSMapping,\n SendDataValue,\n SendHeaders,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer, sendServer } from '@walkeros/server-core';\n\nexport interface Settings {\n url: string;\n headers?: SendHeaders;\n method?: string;\n transform?: Transform;\n timeout?: number;\n}\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n sendServer?: typeof sendServer;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env>;\n\nexport type Destination = DestinationServer.Destination<Types>;\nexport type Config = DestinationServer.Config<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type Transform = (\n data?: unknown,\n config?: Config,\n mapping?: WalkerOSMapping.Rule<Mapping>,\n) => SendDataValue;\n","export * as env from './env';\nexport * as events from './events';\nexport * as mapping from './mapping';\nexport * as outputs from './outputs';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nconst noop = () => Promise.resolve({ ok: true });\n\nexport const init: Env | undefined = {\n sendServer: undefined,\n};\n\nexport const standard: Env = {\n sendServer: Object.assign(noop, {\n // Add any specific properties if needed for sendServer\n }) as unknown as Env['sendServer'],\n};\n","import { getEvent } from '@walkeros/core';\n\nexport function entity_action() {\n const event = getEvent('entity action');\n\n return JSON.stringify(event.data);\n}\n","import type { Mapping } from '@walkeros/core';\nimport type { Rule, Rules } from '../types';\n\nexport const entity_action: Rule = {\n data: 'data',\n};\n\nexport const config = {\n entity: { action: entity_action },\n} satisfies Rules;\n","import { getEvent } from '@walkeros/core';\n\n/**\n * Examples of API calls the destination will make.\n * Tests verify implementation produces these outputs.\n */\n\nconst sampleEvent = getEvent('entity action');\n\n// Full event POST (default behavior)\nexport const fullEventPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom data (via mapping)\nexport const mappedDataPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent.data),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom headers and method\nexport const customOptionsPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: {\n headers: {\n 'X-API-Key': 'YOUR_API_KEY',\n 'Content-Type': 'application/json',\n },\n method: 'PUT',\n timeout: 10000,\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,eAA0B;AAC1B,yBAA2B;;;ACF3B;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,OAAO,MAAM,QAAQ,QAAQ,EAAE,IAAI,KAAK,CAAC;AAExC,IAAM,OAAwB;AAAA,EACnC,YAAY;AACd;AAEO,IAAM,WAAgB;AAAA,EAC3B,YAAY,OAAO,OAAO,MAAM;AAAA;AAAA,EAEhC,CAAC;AACH;;;ACnBA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AAElB,SAAS,gBAAgB;AAC9B,QAAM,YAAQ,sBAAS,eAAe;AAEtC,SAAO,KAAK,UAAU,MAAM,IAAI;AAClC;;;ACNA;AAAA;AAAA;AAAA,uBAAAC;AAAA;AAGO,IAAMA,iBAAsB;AAAA,EACjC,MAAM;AACR;AAEO,IAAM,SAAS;AAAA,EACpB,QAAQ,EAAE,QAAQA,eAAc;AAClC;;;ACTA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAC,eAAyB;AAOzB,IAAM,kBAAc,uBAAS,eAAe;AAGrC,IAAM,gBAAgB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,WAAW;AAAA,EAChC,SAAS,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AACvE;AAGO,IAAM,iBAAiB;AAAA,EAC5B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,YAAY,IAAI;AAAA,EACrC,SAAS,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AACvE;AAGO,IAAM,oBAAoB;AAAA,EAC/B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,WAAW;AAAA,EAChC,SAAS;AAAA,IACP,SAAS;AAAA,MACP,aAAa;AAAA,MACb,gBAAgB;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AACF;;;ANzBO,IAAM,iBAA8B;AAAA,EACzC,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,0CAAW;AAAA,EAElB,MAAM,KAAK,OAAO,EAAE,QAAAC,SAAQ,SAAS,MAAM,KAAK,OAAO,GAAG;AACxD,UAAM,EAAE,SAAS,IAAIA;AACrB,UAAM,EAAE,KAAK,SAAS,QAAQ,WAAW,QAAQ,IAAI,YAAY,CAAC;AAElE,QAAI,CAAC,IAAK;AAEV,UAAM,gBAAY,wBAAU,IAAI,IAAI,OAAO;AAC3C,UAAM,OAAO,YACT,UAAU,WAAWA,SAAQ,OAAO,IACpC,KAAK,UAAU,SAAS;AAE5B,qCAAQ,MAAM,mCAAmC;AAAA,MAC/C;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB,WAAW,MAAM;AAAA,IACnB;AAEA,UAAM,gBAAgB,2BAAa,eAAc;AACjD,UAAM,WAAW,MAAM,aAAa,KAAK,MAAM;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,qCAAQ,MAAM,4BAA4B,EAAE,IAAI,qCAAU,GAAG;AAAA,EAC/D;AACF;AAEA,IAAO,gBAAQ;","names":["import_core","entity_action","import_core","config"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __defProp=Object.defineProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})};import{isDefined}from"@walkeros/core";import{sendServer}from"@walkeros/server-core";var types_exports={},examples_exports={};__export(examples_exports,{env:()=>env_exports,events:()=>events_exports,mapping:()=>mapping_exports,outputs:()=>outputs_exports});var env_exports={};__export(env_exports,{init:()=>init,standard:()=>standard});var init={sendServer:void 0},standard={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},events_exports={};__export(events_exports,{entity_action:()=>entity_action});import{getEvent}from"@walkeros/core";function entity_action(){const event=getEvent("entity action");return JSON.stringify(event.data)}var mapping_exports={};__export(mapping_exports,{config:()=>config,entity_action:()=>entity_action2});var entity_action2={data:"data"},config={entity:{action:entity_action2}},outputs_exports={};__export(outputs_exports,{customOptionsPost:()=>customOptionsPost,fullEventPost:()=>fullEventPost,mappedDataPost:()=>mappedDataPost});import{getEvent as getEvent2}from"@walkeros/core";var sampleEvent=getEvent2("entity action"),fullEventPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent),options:{headers:void 0,method:void 0,timeout:void 0}},mappedDataPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent.data),options:{headers:void 0,method:void 0,timeout:void 0}},customOptionsPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent),options:{headers:{"X-API-Key":"YOUR_API_KEY","Content-Type":"application/json"},method:"PUT",timeout:1e4}},destinationAPI={type:"api",config:{},env:{sendServer:sendServer},async push(event,{config:config2,mapping:mapping,data:data,env:env,logger:logger}){const{settings:settings}=config2,{url:url,headers:headers,method:method,transform:transform,timeout:timeout}=settings||{};if(!url)return;const eventData=isDefined(data)?data:event,body=transform?transform(eventData,config2,mapping):JSON.stringify(eventData);null==logger||logger.debug("API destination sending request",{url:url,method:method||"POST",eventName:event.name});const sendServerFn=(null==env?void 0:env.sendServer)||sendServer,response=await sendServerFn(url,body,{headers:headers,method:method,timeout:timeout});null==logger||logger.debug("API destination response",{ok:null==response?void 0:response.ok})}},index_default=destinationAPI;export{types_exports as DestinationAPI,index_default as default,destinationAPI,examples_exports as examples};//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/events.ts","../src/examples/mapping.ts","../src/examples/outputs.ts"],"sourcesContent":["import type { Settings, Destination, Env } from './types';\nimport { isDefined } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\n\n// Types\nexport * as DestinationAPI from './types';\n\n// Examples\nexport * as examples from './examples';\n\nexport const destinationAPI: Destination = {\n type: 'api',\n\n config: {},\n\n env: { sendServer },\n\n async push(event, { config, mapping, data, env, logger }) {\n const { settings } = config;\n const { url, headers, method, transform, timeout } = settings || {};\n\n if (!url) return;\n\n const eventData = isDefined(data) ? data : event;\n const body = transform\n ? transform(eventData, config, mapping) // Transform event data\n : JSON.stringify(eventData);\n\n logger?.debug('API destination sending request', {\n url,\n method: method || 'POST',\n eventName: event.name,\n });\n\n const sendServerFn = (env as Env)?.sendServer || sendServer;\n const response = await sendServerFn(url, body, {\n headers,\n method,\n timeout,\n });\n\n logger?.debug('API destination response', { ok: response?.ok });\n },\n};\n\nexport default destinationAPI;\n","import type {\n Mapping as WalkerOSMapping,\n SendDataValue,\n SendHeaders,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer, sendServer } from '@walkeros/server-core';\n\nexport interface Settings {\n url: string;\n headers?: SendHeaders;\n method?: string;\n transform?: Transform;\n timeout?: number;\n}\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n sendServer?: typeof sendServer;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env>;\n\nexport type Destination = DestinationServer.Destination<Types>;\nexport type Config = DestinationServer.Config<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type Transform = (\n data?: unknown,\n config?: Config,\n mapping?: WalkerOSMapping.Rule<Mapping>,\n) => SendDataValue;\n","export * as env from './env';\nexport * as events from './events';\nexport * as mapping from './mapping';\nexport * as outputs from './outputs';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nconst noop = () => Promise.resolve({ ok: true });\n\nexport const init: Env | undefined = {\n sendServer: undefined,\n};\n\nexport const standard: Env = {\n sendServer: Object.assign(noop, {\n // Add any specific properties if needed for sendServer\n }) as unknown as Env['sendServer'],\n};\n","import { getEvent } from '@walkeros/core';\n\nexport function entity_action() {\n const event = getEvent('entity action');\n\n return JSON.stringify(event.data);\n}\n","import type { Mapping } from '@walkeros/core';\nimport type { Rule, Rules } from '../types';\n\nexport const entity_action: Rule = {\n data: 'data',\n};\n\nexport const config = {\n entity: { action: entity_action },\n} satisfies Rules;\n","import { getEvent } from '@walkeros/core';\n\n/**\n * Examples of API calls the destination will make.\n * Tests verify implementation produces these outputs.\n */\n\nconst sampleEvent = getEvent('entity action');\n\n// Full event POST (default behavior)\nexport const fullEventPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom data (via mapping)\nexport const mappedDataPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent.data),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom headers and method\nexport const customOptionsPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: {\n headers: {\n 'X-API-Key': 'YOUR_API_KEY',\n 'Content-Type': 'application/json',\n },\n method: 'PUT',\n timeout: 10000,\n },\n};\n"],"mappings":";;;;;;;AACA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;;;ACF3B;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,OAAO,MAAM,QAAQ,QAAQ,EAAE,IAAI,KAAK,CAAC;AAExC,IAAM,OAAwB;AAAA,EACnC,YAAY;AACd;AAEO,IAAM,WAAgB;AAAA,EAC3B,YAAY,OAAO,OAAO,MAAM;AAAA;AAAA,EAEhC,CAAC;AACH;;;ACnBA;AAAA;AAAA;AAAA;AAAA,SAAS,gBAAgB;AAElB,SAAS,gBAAgB;AAC9B,QAAM,QAAQ,SAAS,eAAe;AAEtC,SAAO,KAAK,UAAU,MAAM,IAAI;AAClC;;;ACNA;AAAA;AAAA;AAAA,uBAAAA;AAAA;AAGO,IAAMA,iBAAsB;AAAA,EACjC,MAAM;AACR;AAEO,IAAM,SAAS;AAAA,EACpB,QAAQ,EAAE,QAAQA,eAAc;AAClC;;;ACTA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,YAAAC,iBAAgB;AAOzB,IAAM,cAAcA,UAAS,eAAe;AAGrC,IAAM,gBAAgB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,WAAW;AAAA,EAChC,SAAS,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AACvE;AAGO,IAAM,iBAAiB;AAAA,EAC5B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,YAAY,IAAI;AAAA,EACrC,SAAS,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AACvE;AAGO,IAAM,oBAAoB;AAAA,EAC/B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,WAAW;AAAA,EAChC,SAAS;AAAA,IACP,SAAS;AAAA,MACP,aAAa;AAAA,MACb,gBAAgB;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AACF;;;ANzBO,IAAM,iBAA8B;AAAA,EACzC,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,WAAW;AAAA,EAElB,MAAM,KAAK,OAAO,EAAE,QAAAC,SAAQ,SAAS,MAAM,KAAK,OAAO,GAAG;AACxD,UAAM,EAAE,SAAS,IAAIA;AACrB,UAAM,EAAE,KAAK,SAAS,QAAQ,WAAW,QAAQ,IAAI,YAAY,CAAC;AAElE,QAAI,CAAC,IAAK;AAEV,UAAM,YAAY,UAAU,IAAI,IAAI,OAAO;AAC3C,UAAM,OAAO,YACT,UAAU,WAAWA,SAAQ,OAAO,IACpC,KAAK,UAAU,SAAS;AAE5B,qCAAQ,MAAM,mCAAmC;AAAA,MAC/C;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB,WAAW,MAAM;AAAA,IACnB;AAEA,UAAM,gBAAgB,2BAAa,eAAc;AACjD,UAAM,WAAW,MAAM,aAAa,KAAK,MAAM;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,qCAAQ,MAAM,4BAA4B,EAAE,IAAI,qCAAU,GAAG;AAAA,EAC/D;AACF;AAEA,IAAO,gBAAQ;","names":["entity_action","getEvent","config"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@walkeros/server-destination-api",
|
|
3
|
+
"description": "API server destination for walkerOS",
|
|
4
|
+
"version": "0.0.0-next-20251219153324",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./dev": {
|
|
16
|
+
"types": "./dist/dev.d.ts",
|
|
17
|
+
"import": "./dist/dev.mjs",
|
|
18
|
+
"require": "./dist/dev.js"
|
|
19
|
+
},
|
|
20
|
+
"./examples": {
|
|
21
|
+
"types": "./dist/examples/index.d.ts",
|
|
22
|
+
"import": "./dist/examples/index.mjs",
|
|
23
|
+
"require": "./dist/examples/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/**"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsup --silent",
|
|
31
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
32
|
+
"dev": "jest --watchAll --colors",
|
|
33
|
+
"lint": "tsc && eslint \"**/*.ts*\"",
|
|
34
|
+
"test": "jest",
|
|
35
|
+
"update": "npx npm-check-updates -u && npm update"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@walkeros/core": "0.0.0-next-20251219153324",
|
|
39
|
+
"@walkeros/server-core": "0.0.0-next-20251219153324"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {},
|
|
42
|
+
"repository": {
|
|
43
|
+
"url": "git+https://github.com/elbwalker/walkerOS.git",
|
|
44
|
+
"directory": "packages/server/destinations/api"
|
|
45
|
+
},
|
|
46
|
+
"author": "elbwalker <hello@elbwalker.com>",
|
|
47
|
+
"homepage": "https://github.com/elbwalker/walkerOS#readme",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/elbwalker/walkerOS/issues"
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"walker",
|
|
53
|
+
"walkerOS",
|
|
54
|
+
"destination",
|
|
55
|
+
"server",
|
|
56
|
+
"api"
|
|
57
|
+
],
|
|
58
|
+
"funding": [
|
|
59
|
+
{
|
|
60
|
+
"type": "GitHub Sponsors",
|
|
61
|
+
"url": "https://github.com/sponsors/elbwalker"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|