@digo-org/digo-api 1.0.2 → 1.0.3
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 +105 -2
- package/package.json +1 -1
- package/src/digo-asset.ts +6 -1
- package/src/index.ts +2 -4
- package/src/types.ts +90 -0
package/README.md
CHANGED
@@ -1,3 +1,106 @@
|
|
1
|
-
|
1
|
+
# Digo API
|
2
2
|
|
3
|
-
|
3
|
+
This package provides the API interfaces for DIGO Assets, making them available to other workspaces in the monorepo or external projects via npm.
|
4
|
+
|
5
|
+
|
6
|
+
## Overview
|
7
|
+
|
8
|
+
The Digo API package contains interfaces and utility functions that define and facilitate communication with Digo Assets. These components form the foundation for building applications that work with the Digo ecosystem.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
```bash
|
13
|
+
npm install @digo-org/digo-api
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
```typescript
|
19
|
+
import { DigoApi } from '@digo-org/digo-api';
|
20
|
+
// or specific components
|
21
|
+
import { YourSpecificComponent } from '@digo-org/digo-api';
|
22
|
+
```
|
23
|
+
|
24
|
+
## Updating the Package
|
25
|
+
|
26
|
+
When you need to update the Digo API package, follow these steps:
|
27
|
+
|
28
|
+
1. **Make Your Changes**:
|
29
|
+
- Update existing files or add new files in the `src/` directory
|
30
|
+
- Ensure you export any new types, interfaces, or functions from index.ts
|
31
|
+
|
32
|
+
2. **Update Version**:
|
33
|
+
- Increment the version number in package.json following [Semantic Versioning](https://semver.org/):
|
34
|
+
- MAJOR version for incompatible API changes
|
35
|
+
- MINOR version for backward-compatible functionality
|
36
|
+
- PATCH version for backward-compatible bug fixes
|
37
|
+
|
38
|
+
3. **Build & Test**:
|
39
|
+
```bash
|
40
|
+
# Lint your code
|
41
|
+
npm run lint
|
42
|
+
|
43
|
+
# Fix linting issues automatically
|
44
|
+
npm run lint:fix
|
45
|
+
|
46
|
+
# Build the package
|
47
|
+
npm run build
|
48
|
+
```
|
49
|
+
|
50
|
+
4. **Commit Changes**:
|
51
|
+
- Commit all changes to your repository
|
52
|
+
- Use descriptive commit messages that explain your changes
|
53
|
+
|
54
|
+
5. **Publish**:
|
55
|
+
```bash
|
56
|
+
# The prepublish script will automatically run build
|
57
|
+
npm publish
|
58
|
+
```
|
59
|
+
|
60
|
+
## Understanding package.json
|
61
|
+
|
62
|
+
The package.json file contains important configurations:
|
63
|
+
|
64
|
+
```json
|
65
|
+
{
|
66
|
+
"name": "@digo-org/digo-api", // Package name with org scope
|
67
|
+
"private": false, // Allows publishing to npm
|
68
|
+
"version": "1.0.2", // Current package version
|
69
|
+
"type": "module", // Use ES modules
|
70
|
+
"main": "src/index.ts", // Main entry point
|
71
|
+
"types": "src/index.ts", // TypeScript types entry point
|
72
|
+
"publishConfig": { // Publishing configuration
|
73
|
+
"access": "public" // Makes the scoped package publicly available
|
74
|
+
},
|
75
|
+
"scripts": { // NPM scripts
|
76
|
+
"build": "tsc --build", // Compile TypeScript
|
77
|
+
"lint": "eslint ./src", // Check code quality
|
78
|
+
"lint:fix": "eslint ./src --fix", // Fix code quality issues
|
79
|
+
"prepublish": "rm -rf ./dist && npm run build" // Pre-publish hook
|
80
|
+
},
|
81
|
+
"devDependencies": { // Development dependencies
|
82
|
+
"@digo/dev-dependencies": "*" // Shared dev dependencies
|
83
|
+
}
|
84
|
+
}
|
85
|
+
```
|
86
|
+
|
87
|
+
## Publishing
|
88
|
+
|
89
|
+
Publishing is handled through npm:
|
90
|
+
|
91
|
+
```bash
|
92
|
+
# Login to npm if not already logged in
|
93
|
+
npm login
|
94
|
+
|
95
|
+
# Publish package
|
96
|
+
npm publish
|
97
|
+
```
|
98
|
+
|
99
|
+
The `prepublish` script will automatically:
|
100
|
+
1. Remove the old `dist` directory
|
101
|
+
2. Run the build process to create a new `dist` directory with the latest code
|
102
|
+
|
103
|
+
#### Publishing Issues
|
104
|
+
- Verify you're logged into npm with the correct account
|
105
|
+
- Ensure the version has been incremented
|
106
|
+
- Check that you have the necessary permissions in the @digo-org organization
|
package/package.json
CHANGED
package/src/digo-asset.ts
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
import { ReactNode }
|
1
|
+
import { ReactNode } from 'react';
|
2
|
+
import { SingleParameterValue } from 'src/types';
|
2
3
|
|
3
4
|
export abstract class DigoAsset {
|
5
|
+
public static onParameterChange(_parameterId: string, _entityId: string, _value: SingleParameterValue, _isGlobal: boolean) {
|
6
|
+
// Nothing to do here
|
7
|
+
}
|
8
|
+
|
4
9
|
abstract render(): ReactNode;
|
5
10
|
}
|
package/src/index.ts
CHANGED
package/src/types.ts
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
export interface VizAsset {
|
2
|
+
id: string;
|
3
|
+
name: string;
|
4
|
+
description: string;
|
5
|
+
tags: string[];
|
6
|
+
definition: VizAssetDefinition;
|
7
|
+
template_id: string;
|
8
|
+
last_updated: string;
|
9
|
+
}
|
10
|
+
|
11
|
+
export interface VizAssetDefinition {
|
12
|
+
globalParameters: ParametersValue;
|
13
|
+
instances: Instance[];
|
14
|
+
}
|
15
|
+
|
16
|
+
export interface Instance {
|
17
|
+
id: string;
|
18
|
+
[parameterId: string]: SingleParameterValue;
|
19
|
+
}
|
20
|
+
|
21
|
+
export interface ParametersValue {
|
22
|
+
[parameterId: string]: SingleParameterValue;
|
23
|
+
}
|
24
|
+
|
25
|
+
export interface VizParameterProperties {
|
26
|
+
id: string;
|
27
|
+
group: string;
|
28
|
+
isGlobal: boolean;
|
29
|
+
properties: ParameterProperties;
|
30
|
+
}
|
31
|
+
|
32
|
+
export enum ParameterType {
|
33
|
+
NUMBER,
|
34
|
+
BOOLEAN,
|
35
|
+
COLOR,
|
36
|
+
TEXT,
|
37
|
+
GRADIENT,
|
38
|
+
}
|
39
|
+
|
40
|
+
export type ParameterValue = SingleParameterValue | ArrayParameterValue;
|
41
|
+
|
42
|
+
export type SingleParameterValue = number | boolean | string | GradientStop[];
|
43
|
+
|
44
|
+
export type ArrayParameterValue = number[] | boolean[] | string[] | GradientStop[][];
|
45
|
+
|
46
|
+
export interface ParameterProperties {
|
47
|
+
name?: string;
|
48
|
+
type: ParameterType;
|
49
|
+
definition: ParameterNumberProperties | ParameterBooleanProperties | ParameterColorProperties | ParameterTextProperties | ParameterGradientProperties;
|
50
|
+
isArray?: boolean;
|
51
|
+
arrayValues?: ArrayParameterValue;
|
52
|
+
}
|
53
|
+
|
54
|
+
export interface ParameterNumberProperties {
|
55
|
+
defaultValue: number;
|
56
|
+
min?: number;
|
57
|
+
max?: number;
|
58
|
+
icon: string;
|
59
|
+
decimals?: number;
|
60
|
+
step?: number;
|
61
|
+
units?: string;
|
62
|
+
};
|
63
|
+
|
64
|
+
export interface ParameterGradientProperties {
|
65
|
+
defaultValue: GradientStop[];
|
66
|
+
};
|
67
|
+
|
68
|
+
export interface ParameterTextProperties {
|
69
|
+
defaultValue: string;
|
70
|
+
placeholder?: string;
|
71
|
+
};
|
72
|
+
|
73
|
+
export interface ParameterColorProperties {
|
74
|
+
defaultValue: string;
|
75
|
+
};
|
76
|
+
|
77
|
+
export interface ParameterBooleanProperties {
|
78
|
+
defaultValue: boolean;
|
79
|
+
};
|
80
|
+
|
81
|
+
export interface ParameterArrayProperties {
|
82
|
+
defaultValue: ArrayParameterValue;
|
83
|
+
definition: ParameterNumberProperties | ParameterBooleanProperties | ParameterColorProperties | ParameterTextProperties | ParameterGradientProperties;
|
84
|
+
labels: string[];
|
85
|
+
};
|
86
|
+
|
87
|
+
export interface GradientStop {
|
88
|
+
color: string; // hex
|
89
|
+
percent: number;
|
90
|
+
}
|