zephyr-edge-contract 0.0.48 → 0.0.50

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 CHANGED
@@ -1,5 +1,241 @@
1
- # zephyr-edge-contract (Internal)
1
+ # Zephyr Edge Contract (Internal)
2
2
 
3
- Read more from our documentation [here](https://docs.zephyr-cloud.io).
3
+ <div align="center">
4
4
 
5
- This is a set of API types and reusable functions for zephyr build plugins.
5
+ [Zephyr Cloud](https://zephyr-cloud.io) | [Zephyr Docs](https://docs.zephyr-cloud.io) | [Discord](https://zephyr-cloud.io/discord) | [Twitter](https://x.com/ZephyrCloudIO) | [LinkedIn](https://www.linkedin.com/company/zephyr-cloud/)
6
+
7
+ <hr/>
8
+ <img src="https://cdn.prod.website-files.com/669061ee3adb95b628c3acda/66981c766e352fe1f57191e2_Opengraph-zephyr.png" alt="Zephyr Logo" />
9
+ </div>
10
+
11
+ **Internal Package** - A collection of API types, contracts, and reusable functions for Zephyr build plugins. This package defines the standardized interfaces and utilities used across the Zephyr ecosystem.
12
+
13
+ > **Note**: This is an internal package used by other Zephyr plugins. It is not intended for direct use by end users.
14
+
15
+ ## Overview
16
+
17
+ The Zephyr Edge Contract package provides:
18
+
19
+ - **Type Definitions**: TypeScript interfaces and types for API communication
20
+ - **Contracts**: Standardized contracts for plugin interactions
21
+ - **Utilities**: Reusable utility functions for common operations
22
+ - **Constants**: Shared constants and configuration values
23
+ - **Validation**: Schema validation and type checking utilities
24
+
25
+ ## Package Structure
26
+
27
+ ### API Contract Negotiation (`lib/api-contract-negotiation/`)
28
+
29
+ - Defines API versioning and compatibility contracts
30
+ - Handles contract negotiation between plugins and services
31
+ - Ensures backward compatibility across versions
32
+
33
+ ### Edge API (`lib/edge-api/`)
34
+
35
+ - Type definitions for edge API communication
36
+ - Request/response schemas for deployment operations
37
+ - Environment and publishing request interfaces
38
+
39
+ ### Plugin Options (`lib/plugin-options/`)
40
+
41
+ - Standardized plugin configuration interfaces
42
+ - Common options shared across Webpack/Rspack plugins
43
+ - Type-safe configuration validation
44
+
45
+ ### Promise Utilities (`lib/promise/`)
46
+
47
+ - Promise-based utility functions and helpers
48
+ - Deferred promise implementations
49
+ - Lazy loading and tuple promise utilities
50
+ - Concurrency control with `forEachLimit`
51
+
52
+ ### String Utilities (`lib/string/`)
53
+
54
+ - String manipulation and formatting utilities
55
+ - ANSI color code stripping functions
56
+ - String parsing and validation helpers
57
+
58
+ ### General Utilities (`lib/utils/`)
59
+
60
+ - Application UID generation
61
+ - Snapshot ID creation
62
+ - Safe JSON parsing utilities
63
+ - Common helper functions
64
+
65
+ ### Zephyr API (`lib/ze-api/`)
66
+
67
+ - API interfaces for Zephyr Cloud services
68
+ - Application listing and version management
69
+ - Dependency graph and package.json handling
70
+
71
+ ## Type Definitions
72
+
73
+ ### Build Stats Contract
74
+
75
+ ```typescript
76
+ interface ZephyrBuildStats {
77
+ bundler: string;
78
+ buildTime: number;
79
+ assets: AssetInfo[];
80
+ chunks: ChunkInfo[];
81
+ modules: ModuleInfo[];
82
+ dependencies: DependencyInfo[];
83
+ }
84
+ ```
85
+
86
+ ### Edge Contract
87
+
88
+ ```typescript
89
+ interface ZephyrEdgeContract {
90
+ version: string;
91
+ capabilities: string[];
92
+ endpoints: EdgeEndpoints;
93
+ authentication: AuthConfig;
94
+ }
95
+ ```
96
+
97
+ ### Plugin Configuration
98
+
99
+ ```typescript
100
+ interface ZephyrPluginOptions {
101
+ deploy?: boolean;
102
+ environment?: string;
103
+ metadata?: Record<string, any>;
104
+ buildContext?: BuildContext;
105
+ }
106
+ ```
107
+
108
+ ## Utility Functions
109
+
110
+ ### Promise Utilities
111
+
112
+ ```typescript
113
+ // Deferred promise implementation
114
+ const deferred = createDeferred<T>();
115
+
116
+ // Lazy promise loading
117
+ const lazyPromise = createLazyPromise(() => expensiveOperation());
118
+
119
+ // Controlled concurrency
120
+ await forEachLimit(items, 3, async (item) => processItem(item));
121
+ ```
122
+
123
+ ### String Utilities
124
+
125
+ ```typescript
126
+ // Strip ANSI color codes
127
+ const cleanText = stripAnsi(coloredText);
128
+
129
+ // String validation and parsing
130
+ const isValid = validateString(input, schema);
131
+ ```
132
+
133
+ ### ID Generation
134
+
135
+ ```typescript
136
+ // Generate application UID
137
+ const appUid = createApplicationUid(packageName, version);
138
+
139
+ // Create snapshot ID
140
+ const snapshotId = createSnapshotId(buildInfo);
141
+ ```
142
+
143
+ ## Schema Validation
144
+
145
+ The package includes JSON schema definitions for:
146
+
147
+ - **Dependency Schemas**: Validation for Zephyr dependencies
148
+ - **Build Context**: Build-time context validation
149
+ - **API Requests**: Request/response validation
150
+ - **Plugin Options**: Configuration schema validation
151
+
152
+ ## Constants and Enums
153
+
154
+ ```typescript
155
+ // API versions
156
+ export const API_VERSIONS = {
157
+ V1: 'v1',
158
+ V2: 'v2',
159
+ CURRENT: 'v2',
160
+ } as const;
161
+
162
+ // Build environments
163
+ export const ENVIRONMENTS = {
164
+ DEVELOPMENT: 'development',
165
+ STAGING: 'staging',
166
+ PRODUCTION: 'production',
167
+ } as const;
168
+
169
+ // Plugin types
170
+ export const PLUGIN_TYPES = {
171
+ WEBPACK: 'webpack',
172
+ RSPACK: 'rspack',
173
+ VITE: 'vite',
174
+ ROLLUP: 'rollup',
175
+ } as const;
176
+ ```
177
+
178
+ ## Error Handling
179
+
180
+ Standardized error types and handling:
181
+
182
+ ```typescript
183
+ interface ZephyrError {
184
+ code: string;
185
+ message: string;
186
+ details?: Record<string, any>;
187
+ stack?: string;
188
+ }
189
+
190
+ // Error creation utilities
191
+ const error = createZephyrError('INVALID_CONFIG', 'Configuration is invalid');
192
+ ```
193
+
194
+ ## Usage by Plugins
195
+
196
+ Internal packages use this contract for consistency:
197
+
198
+ ```typescript
199
+ import { ZephyrPluginOptions, createApplicationUid, stripAnsi, forEachLimit } from 'zephyr-edge-contract';
200
+
201
+ // Type-safe plugin configuration
202
+ function createPlugin(options: ZephyrPluginOptions) {
203
+ // Implementation
204
+ }
205
+
206
+ // Utility usage
207
+ const appId = createApplicationUid('my-app', '1.0.0');
208
+ const cleanOutput = stripAnsi(buildOutput);
209
+ ```
210
+
211
+ ## Development
212
+
213
+ For internal development and testing:
214
+
215
+ ```bash
216
+ # Build the package
217
+ npm run build
218
+
219
+ # Run tests
220
+ npm run test
221
+
222
+ # Type checking
223
+ npm run type-check
224
+ ```
225
+
226
+ ## API Compatibility
227
+
228
+ The package maintains strict API compatibility through:
229
+
230
+ - **Semantic Versioning**: Breaking changes only in major versions
231
+ - **Contract Negotiation**: Runtime compatibility checking
232
+ - **Schema Evolution**: Backward-compatible schema updates
233
+ - **Type Safety**: Compile-time type checking
234
+
235
+ ## Contributing
236
+
237
+ This is an internal package. Contributions should be made through the main Zephyr plugins repository. Please read our [contributing guidelines](../../CONTRIBUTING.md) for more information.
238
+
239
+ ## License
240
+
241
+ Licensed under the Apache-2.0 License. See [LICENSE](LICENSE) for more information.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zephyr-edge-contract",
3
- "version": "0.0.48",
3
+ "version": "0.0.50",
4
4
  "description": "Edge contract for Zephyr",
5
5
  "repository": {
6
6
  "type": "git",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zephyr-edge-contract",
3
- "version": "0.0.48",
3
+ "version": "0.0.50",
4
4
  "description": "Edge contract for Zephyr",
5
5
  "repository": {
6
6
  "type": "git",