@fy-stack/types 0.0.125 → 0.0.127
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 +59 -4
- package/dist/lib/types.d.ts +48 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,7 +1,62 @@
|
|
|
1
|
-
# types
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
# FY-Stack Types
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
This module defines several interfaces for managing FY-Stack resources. These interfaces support actions like attaching resources, granting permissions, and integrating with CloudFront, SNS, and API Gateway.
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
## Interfaces
|
|
7
|
+
|
|
8
|
+
### `Attachable`
|
|
9
|
+
Represents a resource that can be attached to other resources.
|
|
10
|
+
|
|
11
|
+
- **Method**
|
|
12
|
+
- `attachable(): Record<string, string>`
|
|
13
|
+
Returns a set of key-value pairs representing the attributes needed to attach this resource to another. The keys and values in the returned object are specific to the resource.
|
|
14
|
+
|
|
15
|
+
### `Attach`
|
|
16
|
+
Represents a resource that can attach `Attachable` resources to itself.
|
|
17
|
+
|
|
18
|
+
- **Method**
|
|
19
|
+
- `attach(attachable: Record<string, Attachable>): void`
|
|
20
|
+
Takes an object of `Attachable` resources and attaches each to the current resource. The `Attachable` resources are provided as a map, where each key-value pair represents a resource to be attached.
|
|
21
|
+
|
|
22
|
+
### `Grantable`
|
|
23
|
+
Represents a resource that can grant permissions to other resources.
|
|
24
|
+
|
|
25
|
+
- **Method**
|
|
26
|
+
- `grantable(grant: IGrantable): void`
|
|
27
|
+
Accepts an `IGrantable` object and grants it the necessary permissions to interact with this resource.
|
|
28
|
+
|
|
29
|
+
### `Grant`
|
|
30
|
+
Represents a resource that can be granted permissions by other resources.
|
|
31
|
+
|
|
32
|
+
- **Method**
|
|
33
|
+
- `grant(...grantables: Grantable[]): void`
|
|
34
|
+
Accepts multiple `Grantable` resources and initializes permission grants for each. This allows the resource to manage permission relationships with multiple other resources.
|
|
35
|
+
|
|
36
|
+
### `CDNResource`
|
|
37
|
+
Represents a resource that can be associated with a CloudFront distribution.
|
|
38
|
+
|
|
39
|
+
- **Method**
|
|
40
|
+
- `cloudfront(path: string): Record<string, BehaviorOptions>`
|
|
41
|
+
Generates and returns a mapping of paths to CloudFront `BehaviorOptions`, which define how the resource should behave when distributed via CloudFront.
|
|
42
|
+
|
|
43
|
+
### `Event`
|
|
44
|
+
Represents a resource that can subscribe to an SNS topic.
|
|
45
|
+
|
|
46
|
+
- **Method**
|
|
47
|
+
- `subscription(props: SubscriptionProps): ITopicSubscription`
|
|
48
|
+
Subscribes the resource to an SNS topic using the provided subscription properties. Returns an `ITopicSubscription` object representing the subscription.
|
|
49
|
+
|
|
50
|
+
### `ApiResource`
|
|
51
|
+
Represents a resource that can be integrated with an API Gateway.
|
|
52
|
+
|
|
53
|
+
- **Method**
|
|
54
|
+
- `api(path: string): Record<string, HttpRouteIntegration>`
|
|
55
|
+
Generates a mapping of paths to API Gateway `HttpRouteIntegration`, allowing the resource to be exposed via an API Gateway route.
|
|
56
|
+
|
|
57
|
+
### `ResourceRef`
|
|
58
|
+
A type definition for referencing existing resources within an application, identified by name.
|
|
59
|
+
|
|
60
|
+
- **Properties**
|
|
61
|
+
- `$resource: T`
|
|
62
|
+
Represents the name of the application or resource, allowing it to be referenced by name within the system. This is useful for referencing resources like `auth` or `uploads`.
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -3,28 +3,76 @@ import type { BehaviorOptions } from 'aws-cdk-lib/aws-cloudfront';
|
|
|
3
3
|
import type { IGrantable } from 'aws-cdk-lib/aws-iam';
|
|
4
4
|
import type { ITopicSubscription } from 'aws-cdk-lib/aws-sns';
|
|
5
5
|
import type { SubscriptionProps } from 'aws-cdk-lib/aws-sns-subscriptions';
|
|
6
|
+
/**
|
|
7
|
+
* Resource can be attached to other resources
|
|
8
|
+
* */
|
|
6
9
|
export interface Attachable {
|
|
10
|
+
/**
|
|
11
|
+
* Return values needed to enable resource to be attached
|
|
12
|
+
* */
|
|
7
13
|
attachable(): Record<string, string>;
|
|
8
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Other resources can be attached to this resource
|
|
17
|
+
* */
|
|
9
18
|
export interface Attach {
|
|
19
|
+
/**
|
|
20
|
+
* Attach Attachable resources to Resource
|
|
21
|
+
* */
|
|
10
22
|
attach(attachable: Record<string, Attachable>): void;
|
|
11
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Resource can grant permission resources
|
|
26
|
+
* */
|
|
12
27
|
export interface Grantable {
|
|
28
|
+
/**
|
|
29
|
+
* Grant permissions to IGrantable resource
|
|
30
|
+
* */
|
|
13
31
|
grantable(grant: IGrantable): void;
|
|
14
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Resource can be granted permissions by resources
|
|
35
|
+
* */
|
|
15
36
|
export interface Grant {
|
|
37
|
+
/**
|
|
38
|
+
* Initialize permission grants from Grantable resources
|
|
39
|
+
* */
|
|
16
40
|
grant(...grantables: Grantable[]): void;
|
|
17
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Resource can be attached to a Cloudfront distribution
|
|
44
|
+
* */
|
|
18
45
|
export interface CDNResource {
|
|
46
|
+
/**
|
|
47
|
+
* Generate map of paths to Cloudfront BehaviorOptions.
|
|
48
|
+
* */
|
|
19
49
|
cloudfront(path: string): Record<string, BehaviorOptions>;
|
|
20
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Resource can subscribe to an SNS topic
|
|
53
|
+
* */
|
|
21
54
|
export interface Event {
|
|
55
|
+
/**
|
|
56
|
+
* Subscribe to SNS topic.
|
|
57
|
+
* */
|
|
22
58
|
subscription(props: SubscriptionProps): ITopicSubscription;
|
|
23
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Resource can be attached to an API gateway
|
|
62
|
+
* */
|
|
24
63
|
export interface ApiResource {
|
|
64
|
+
/**
|
|
65
|
+
* Generate map of paths to API gateway HttpRouteIntegration.
|
|
66
|
+
* */
|
|
25
67
|
api(path: string): Record<string, HttpRouteIntegration>;
|
|
26
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Reference existing application or resource e.g. auth.
|
|
71
|
+
* */
|
|
27
72
|
export type ResourceRef<T extends string = string> = {
|
|
73
|
+
/**
|
|
74
|
+
* Name of app or resources e.g. uploads, auth.
|
|
75
|
+
* */
|
|
28
76
|
$resource: T;
|
|
29
77
|
};
|
|
30
78
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,MAAM,WAAW,UAAU;IACzB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,KAAK;IACpB,KAAK,CAAC,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAA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AAM,EAAE,eAAe,CAAC,CAAC;CAC3D;AAED;;KAEK;AACL,MAAM,WAAW,KAAK;IACpB;;SAEK;IACL,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,kBAAkB,CAAC;CAC5D;AAED;;KAEK;AACL,MAAM,WAAW,WAAW;IAC1B;;SAEK;IACL,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;CACzD;AAED;;KAEK;AACL,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IACnD;;SAEK;IACL,SAAS,EAAE,CAAC,CAAC;CACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-stack/types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.127",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"tslib": "^2.3.0"
|
|
6
|
-
|
|
5
|
+
"tslib": "^2.3.0"
|
|
6
|
+
},
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"aws-cdk-lib": "2.166.0"
|
|
7
9
|
},
|
|
8
10
|
"type": "commonjs",
|
|
9
11
|
"main": "./dist/index.js",
|