@polymorphism-tech/morph-spec 11.2.0 → 11.3.0

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.
Files changed (109) hide show
  1. package/README.md +3 -2
  2. package/bin/morph-spec.js +7 -7
  3. package/docs/CHEATSHEET.md +1 -1
  4. package/docs/QUICKSTART.md +1 -1
  5. package/framework/CLAUDE.md +1 -1
  6. package/framework/MORPH.md +2 -2
  7. package/framework/agents.json +4 -4
  8. package/framework/docs/CLI.md +19 -11
  9. package/framework/evals/review-checklist.md +26 -2
  10. package/framework/hooks/README.md +3 -2
  11. package/framework/hooks/claude-code/core/graph-refresh-kick.js +2 -2
  12. package/framework/mcp/registry.json +15 -15
  13. package/framework/rules/ai-agents-standards.md +9 -1
  14. package/framework/rules/gsap-standards.md +8 -0
  15. package/framework/rules/mcp-standards.md +10 -0
  16. package/framework/schemas/config.schema.json +7 -0
  17. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  18. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  19. package/framework/skills/core/morph-apply/SKILL.md +4 -3
  20. package/framework/skills/core/morph-plan/SKILL.md +1 -1
  21. package/framework/skills/core/morph-uiux/SKILL.md +1 -1
  22. package/framework/standards/STANDARDS.json +8 -4
  23. package/framework/standards/STANDARDS.meta.json +1 -1
  24. package/framework/standards/ai-agents/agent-archetypes.md +1 -1
  25. package/framework/standards/ai-agents/middleware-patterns.md +0 -2
  26. package/framework/standards/ai-agents/prompt-sources.md +2 -2
  27. package/framework/standards/ai-agents/providers/model-registry.md +9 -12
  28. package/framework/standards/ai-agents/rag-custom-pgvector.md +2 -9
  29. package/framework/standards/frontend/design-system/ai-image-generation.md +1 -1
  30. package/framework/standards/infrastructure/docker/local-compose-isolation.md +2 -2
  31. package/framework/standards/integration/mcp/mcp-tools.md +124 -266
  32. package/framework/templates/README.md +52 -82
  33. package/framework/templates/REGISTRY.json +0 -206
  34. package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +3 -4
  35. package/framework/templates/context/design-system.md +1 -1
  36. package/framework/templates/docs/plan.md +1 -1
  37. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/model-registry.v2.json +1 -1
  38. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaDisclosureTests.cs +1 -1
  39. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Morph.AiKit.Tests.csproj +2 -4
  40. package/framework/templates/frontend/nextjs/gsap-scroll-section.tsx.hbs +13 -17
  41. package/framework/templates/infrastructure/github/README.md +10 -13
  42. package/package.json +2 -2
  43. package/src/commands/mcp/manual-setup.js +95 -0
  44. package/src/commands/mcp/mcp-setup.js +23 -191
  45. package/src/commands/project/doctor.js +6 -16
  46. package/src/commands/project/init-contract.js +2 -2
  47. package/src/commands/project/init.js +15 -133
  48. package/src/commands/project/stack-scan.js +6 -14
  49. package/src/commands/project/stack-set.js +1 -1
  50. package/src/commands/project/standards.js +1 -2
  51. package/src/commands/project/update.js +52 -66
  52. package/src/commands/scaffold/scaffold.js +28 -7
  53. package/src/lib/ai/ai-project-scan.js +1 -4
  54. package/src/lib/ai/code-audit.js +1 -6
  55. package/src/lib/ai/registry-audit.js +2 -1
  56. package/src/lib/config/project-config.js +3 -2
  57. package/src/lib/contract/apply.js +2 -1
  58. package/src/lib/contract/merge.js +1 -0
  59. package/src/lib/contract/scan.js +5 -5
  60. package/src/lib/detectors/claude-config-detector.js +45 -47
  61. package/src/lib/detectors/mcp-config.js +2 -1
  62. package/src/lib/diff/diff-lines.js +2 -7
  63. package/src/lib/graph/graph-loader.js +2 -1
  64. package/src/lib/graph/graphifyignore.js +2 -1
  65. package/src/lib/installers/install-manifest.js +56 -0
  66. package/src/lib/installers/mcp-installer.js +14 -5
  67. package/src/lib/installers/rules-installer.js +9 -15
  68. package/src/lib/installers/stack-assets.js +42 -21
  69. package/src/lib/installers/stack-sync.js +12 -12
  70. package/src/lib/installers/stack-tooling.js +4 -3
  71. package/src/lib/json-file.js +9 -0
  72. package/src/lib/plan/artifact-vocabulary.js +1 -1
  73. package/src/lib/plan/checks.js +3 -2
  74. package/src/lib/plan/media.js +3 -3
  75. package/src/lib/plan/plan-parser.js +5 -10
  76. package/src/lib/review-reports.js +5 -4
  77. package/src/lib/stack/stack-scan.js +1 -1
  78. package/src/lib/standards/verified-against.js +1 -1
  79. package/src/lib/tests-audit/audit.js +1 -1
  80. package/src/lib/text.js +5 -0
  81. package/src/scripts/setup-infra.js +22 -33
  82. package/src/utils/agents-installer.js +13 -30
  83. package/src/utils/claude-md-injector.js +16 -50
  84. package/src/utils/claude-settings-manager.js +2 -2
  85. package/src/utils/file-copier.js +3 -4
  86. package/src/utils/hooks-installer.js +55 -20
  87. package/src/utils/skills-installer.js +18 -78
  88. package/framework/templates/IDE-SNIPPETS.md +0 -262
  89. package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +0 -26
  90. package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +0 -28
  91. package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +0 -99
  92. package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +0 -40
  93. package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +0 -54
  94. package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +0 -53
  95. package/framework/templates/code/dotnet/contracts/README.md +0 -74
  96. package/framework/templates/code/dotnet/database/vector-entity.cs +0 -49
  97. package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +0 -91
  98. package/framework/templates/code/sql/postgresql-migration.template.sql +0 -108
  99. package/framework/templates/code/typescript/contracts.ts +0 -140
  100. package/framework/templates/examples/design-system-examples.md +0 -354
  101. package/framework/templates/infrastructure/docker/Dockerfile.template +0 -58
  102. package/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +0 -45
  103. package/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +0 -27
  104. package/framework/templates/integrations/asaas-client.cs +0 -332
  105. package/framework/templates/integrations/asaas-webhook.cs +0 -290
  106. package/framework/templates/integrations/neon-auth-config.cs +0 -170
  107. package/framework/templates/ui/design-system.css +0 -226
  108. package/src/lib/detectors/index.js +0 -153
  109. package/src/lib/installers/templates-reconcile.js +0 -26
@@ -1,58 +0,0 @@
1
- # Multi-stage Dockerfile for Next.js Production Build
2
- # Optimized for Next.js 15 with App Router
3
-
4
- FROM node:20-alpine AS base
5
-
6
- # Install dependencies only when needed
7
- FROM base AS deps
8
- RUN apk add --no-cache libc6-compat
9
- WORKDIR /app
10
-
11
- # Copy package files
12
- COPY package.json package-lock.json* ./
13
- RUN npm ci
14
-
15
- # Rebuild the source code only when needed
16
- FROM base AS builder
17
- WORKDIR /app
18
- COPY --from=deps /app/node_modules ./node_modules
19
- COPY . .
20
-
21
- # Set build-time environment variables
22
- ENV NEXT_TELEMETRY_DISABLED 1
23
-
24
- # Build Next.js application
25
- RUN npm run build
26
-
27
- # Production image, copy all the files and run next
28
- FROM base AS runner
29
- WORKDIR /app
30
-
31
- ENV NODE_ENV production
32
- ENV NEXT_TELEMETRY_DISABLED 1
33
-
34
- # Create nextjs user
35
- RUN addgroup --system --gid 1001 nodejs
36
- RUN adduser --system --uid 1001 nextjs
37
-
38
- # Copy built application
39
- COPY --from=builder /app/public ./public
40
-
41
- # Set the correct permission for prerender cache
42
- RUN mkdir .next
43
- RUN chown nextjs:nodejs .next
44
-
45
- # Automatically leverage output traces to reduce image size
46
- # https://nextjs.org/docs/advanced-features/output-file-tracing
47
- COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
48
- COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
49
-
50
- USER nextjs
51
-
52
- EXPOSE 3000
53
-
54
- ENV PORT 3000
55
- ENV HOSTNAME "0.0.0.0"
56
-
57
- # Run Next.js server
58
- CMD ["node", "server.js"]
@@ -1,45 +0,0 @@
1
- name: 'Build & Push Docker Image'
2
- description: 'Build multi-stage Docker image and push to registry'
3
- inputs:
4
- registry:
5
- description: 'Docker registry URL'
6
- required: true
7
- image-name:
8
- description: 'Docker image name'
9
- required: true
10
- dockerfile-path:
11
- description: 'Path to Dockerfile'
12
- required: false
13
- default: 'Dockerfile'
14
- build-context:
15
- description: 'Docker build context'
16
- required: false
17
- default: '.'
18
- outputs:
19
- image-tag:
20
- description: 'Full image tag with registry'
21
- value: ${{{{ steps.build.outputs.tags }}}}
22
-
23
- runs:
24
- using: 'composite'
25
- steps:
26
- - name: Set up Docker Buildx
27
- uses: docker/setup-buildx-action@v3
28
-
29
- - name: Login to Registry
30
- uses: docker/login-action@v3
31
- with:
32
- registry: ${{{{ inputs.registry }}}}
33
- username: ${{{{ secrets.REGISTRY_USERNAME }}}}
34
- password: ${{{{ secrets.REGISTRY_PASSWORD }}}}
35
-
36
- - name: Build and push
37
- id: build
38
- uses: docker/build-push-action@v5
39
- with:
40
- context: ${{{{ inputs.build-context }}}}
41
- file: ${{{{ inputs.dockerfile-path }}}}
42
- push: true
43
- tags: ${{{{ inputs.registry }}}}/${{{{ inputs.image-name }}}}:${{{{ github.sha }}}}
44
- cache-from: type=gha
45
- cache-to: type=gha,mode=max
@@ -1,27 +0,0 @@
1
- name: 'Health Check'
2
- description: 'Poll health endpoint until ready'
3
- inputs:
4
- url:
5
- description: 'Health check URL'
6
- required: true
7
- timeout:
8
- description: 'Timeout in seconds'
9
- required: false
10
- default: '300'
11
- interval:
12
- description: 'Polling interval in seconds'
13
- required: false
14
- default: '5'
15
-
16
- runs:
17
- using: 'composite'
18
- steps:
19
- - name: Wait for health
20
- shell: bash
21
- run: |
22
- RETRIES=$(($${{{{ inputs.timeout }}}} / ${{{{ inputs.interval }}}}))
23
- curl --retry $RETRIES \
24
- --retry-delay ${{{{ inputs.interval }}}} \
25
- --retry-connrefused \
26
- --fail \
27
- ${{{{ inputs.url }}}}
@@ -1,332 +0,0 @@
1
- using System.Net.Http.Json;
2
- using System.Text.Json.Serialization;
3
- using Microsoft.Extensions.Logging;
4
- using Microsoft.Extensions.Options;
5
-
6
- namespace {{Namespace}}.Infrastructure.Services;
7
-
8
- public class AsaasOptions
9
- {
10
- public const string SectionName = "Asaas";
11
-
12
- // Produção: https://www.asaas.com/api/v3
13
- public string BaseUrl { get; set; } = "https://sandbox.asaas.com/api/v3";
14
-
15
- public string ApiKey { get; set; } = string.Empty;
16
- }
17
-
18
- public interface IAsaasClient
19
- {
20
- Task<AsaasCustomer> CreateCustomerAsync(CreateCustomerRequest request, CancellationToken ct = default);
21
- Task<AsaasCustomer?> GetCustomerByIdAsync(string customerId, CancellationToken ct = default);
22
- Task<AsaasCustomer?> GetCustomerByCpfCnpjAsync(string cpfCnpj, CancellationToken ct = default);
23
-
24
- Task<AsaasPayment> CreatePaymentAsync(CreatePaymentRequest request, CancellationToken ct = default);
25
- Task<AsaasPayment?> GetPaymentAsync(string paymentId, CancellationToken ct = default);
26
- Task<AsaasPixQrCode?> GetPixQrCodeAsync(string paymentId, CancellationToken ct = default);
27
-
28
- Task<AsaasSubscription> CreateSubscriptionAsync(CreateSubscriptionRequest request, CancellationToken ct = default);
29
- Task<AsaasSubscription?> GetSubscriptionAsync(string subscriptionId, CancellationToken ct = default);
30
- Task CancelSubscriptionAsync(string subscriptionId, CancellationToken ct = default);
31
- }
32
-
33
- public class AsaasClient : IAsaasClient
34
- {
35
- private readonly HttpClient _httpClient;
36
- private readonly ILogger<AsaasClient> _logger;
37
-
38
- public AsaasClient(HttpClient httpClient, ILogger<AsaasClient> logger)
39
- {
40
- _httpClient = httpClient;
41
- _logger = logger;
42
- }
43
-
44
- public async Task<AsaasCustomer> CreateCustomerAsync(CreateCustomerRequest request, CancellationToken ct = default)
45
- {
46
- _logger.LogInformation("Creating Asaas customer: {Name}", request.Name);
47
-
48
- var response = await _httpClient.PostAsJsonAsync("customers", request, ct);
49
- await EnsureSuccessAsync(response, "create customer");
50
-
51
- return await response.Content.ReadFromJsonAsync<AsaasCustomer>(ct)
52
- ?? throw new AsaasException("Failed to deserialize customer response");
53
- }
54
-
55
- public async Task<AsaasCustomer?> GetCustomerByIdAsync(string customerId, CancellationToken ct = default)
56
- {
57
- var response = await _httpClient.GetAsync($"customers/{customerId}", ct);
58
-
59
- if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
60
- return null;
61
-
62
- await EnsureSuccessAsync(response, "get customer");
63
- return await response.Content.ReadFromJsonAsync<AsaasCustomer>(ct);
64
- }
65
-
66
- public async Task<AsaasCustomer?> GetCustomerByCpfCnpjAsync(string cpfCnpj, CancellationToken ct = default)
67
- {
68
- var response = await _httpClient.GetAsync($"customers?cpfCnpj={cpfCnpj}", ct);
69
- await EnsureSuccessAsync(response, "search customer");
70
-
71
- var result = await response.Content.ReadFromJsonAsync<AsaasListResponse<AsaasCustomer>>(ct);
72
- return result?.Data?.FirstOrDefault();
73
- }
74
-
75
- public async Task<AsaasPayment> CreatePaymentAsync(CreatePaymentRequest request, CancellationToken ct = default)
76
- {
77
- _logger.LogInformation("Creating Asaas payment for customer {CustomerId}, type {BillingType}, value {Value}",
78
- request.Customer, request.BillingType, request.Value);
79
-
80
- var response = await _httpClient.PostAsJsonAsync("payments", request, ct);
81
- await EnsureSuccessAsync(response, "create payment");
82
-
83
- return await response.Content.ReadFromJsonAsync<AsaasPayment>(ct)
84
- ?? throw new AsaasException("Failed to deserialize payment response");
85
- }
86
-
87
- public async Task<AsaasPayment?> GetPaymentAsync(string paymentId, CancellationToken ct = default)
88
- {
89
- var response = await _httpClient.GetAsync($"payments/{paymentId}", ct);
90
-
91
- if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
92
- return null;
93
-
94
- await EnsureSuccessAsync(response, "get payment");
95
- return await response.Content.ReadFromJsonAsync<AsaasPayment>(ct);
96
- }
97
-
98
- public async Task<AsaasPixQrCode?> GetPixQrCodeAsync(string paymentId, CancellationToken ct = default)
99
- {
100
- var response = await _httpClient.GetAsync($"payments/{paymentId}/pixQrCode", ct);
101
-
102
- if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
103
- return null;
104
-
105
- await EnsureSuccessAsync(response, "get pix qrcode");
106
- return await response.Content.ReadFromJsonAsync<AsaasPixQrCode>(ct);
107
- }
108
-
109
- public async Task<AsaasSubscription> CreateSubscriptionAsync(CreateSubscriptionRequest request, CancellationToken ct = default)
110
- {
111
- _logger.LogInformation("Creating Asaas subscription for customer {CustomerId}", request.Customer);
112
-
113
- var response = await _httpClient.PostAsJsonAsync("subscriptions", request, ct);
114
- await EnsureSuccessAsync(response, "create subscription");
115
-
116
- return await response.Content.ReadFromJsonAsync<AsaasSubscription>(ct)
117
- ?? throw new AsaasException("Failed to deserialize subscription response");
118
- }
119
-
120
- public async Task<AsaasSubscription?> GetSubscriptionAsync(string subscriptionId, CancellationToken ct = default)
121
- {
122
- var response = await _httpClient.GetAsync($"subscriptions/{subscriptionId}", ct);
123
-
124
- if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
125
- return null;
126
-
127
- await EnsureSuccessAsync(response, "get subscription");
128
- return await response.Content.ReadFromJsonAsync<AsaasSubscription>(ct);
129
- }
130
-
131
- public async Task CancelSubscriptionAsync(string subscriptionId, CancellationToken ct = default)
132
- {
133
- _logger.LogInformation("Canceling Asaas subscription {SubscriptionId}", subscriptionId);
134
-
135
- var response = await _httpClient.DeleteAsync($"subscriptions/{subscriptionId}", ct);
136
- await EnsureSuccessAsync(response, "cancel subscription");
137
- }
138
-
139
- private async Task EnsureSuccessAsync(HttpResponseMessage response, string operation)
140
- {
141
- if (!response.IsSuccessStatusCode)
142
- {
143
- var error = await response.Content.ReadAsStringAsync();
144
- _logger.LogError("Asaas API error during {Operation}: {StatusCode} - {Error}",
145
- operation, response.StatusCode, error);
146
- throw new AsaasException($"Failed to {operation}: {response.StatusCode} - {error}");
147
- }
148
- }
149
- }
150
-
151
- public record CreateCustomerRequest
152
- {
153
- [JsonPropertyName("name")]
154
- public required string Name { get; init; }
155
-
156
- [JsonPropertyName("cpfCnpj")]
157
- public required string CpfCnpj { get; init; }
158
-
159
- [JsonPropertyName("email")]
160
- public string? Email { get; init; }
161
-
162
- [JsonPropertyName("phone")]
163
- public string? Phone { get; init; }
164
-
165
- [JsonPropertyName("mobilePhone")]
166
- public string? MobilePhone { get; init; }
167
-
168
- [JsonPropertyName("externalReference")]
169
- public string? ExternalReference { get; init; }
170
- }
171
-
172
- public record CreatePaymentRequest
173
- {
174
- [JsonPropertyName("customer")]
175
- public required string Customer { get; init; }
176
-
177
- [JsonPropertyName("billingType")]
178
- public required string BillingType { get; init; } // BOLETO, PIX, CREDIT_CARD
179
-
180
- [JsonPropertyName("value")]
181
- public required decimal Value { get; init; }
182
-
183
- [JsonPropertyName("dueDate")]
184
- public required string DueDate { get; init; } // yyyy-MM-dd
185
-
186
- [JsonPropertyName("description")]
187
- public string? Description { get; init; }
188
-
189
- [JsonPropertyName("externalReference")]
190
- public string? ExternalReference { get; init; }
191
- }
192
-
193
- public record CreateSubscriptionRequest
194
- {
195
- [JsonPropertyName("customer")]
196
- public required string Customer { get; init; }
197
-
198
- [JsonPropertyName("billingType")]
199
- public required string BillingType { get; init; }
200
-
201
- [JsonPropertyName("value")]
202
- public required decimal Value { get; init; }
203
-
204
- [JsonPropertyName("nextDueDate")]
205
- public required string NextDueDate { get; init; }
206
-
207
- [JsonPropertyName("cycle")]
208
- public required string Cycle { get; init; } // MONTHLY, WEEKLY, BIWEEKLY, YEARLY
209
-
210
- [JsonPropertyName("description")]
211
- public string? Description { get; init; }
212
-
213
- [JsonPropertyName("externalReference")]
214
- public string? ExternalReference { get; init; }
215
- }
216
-
217
- public record AsaasCustomer
218
- {
219
- [JsonPropertyName("id")]
220
- public string Id { get; init; } = string.Empty;
221
-
222
- [JsonPropertyName("name")]
223
- public string Name { get; init; } = string.Empty;
224
-
225
- [JsonPropertyName("cpfCnpj")]
226
- public string CpfCnpj { get; init; } = string.Empty;
227
-
228
- [JsonPropertyName("email")]
229
- public string? Email { get; init; }
230
-
231
- [JsonPropertyName("externalReference")]
232
- public string? ExternalReference { get; init; }
233
- }
234
-
235
- public record AsaasPayment
236
- {
237
- [JsonPropertyName("id")]
238
- public string Id { get; init; } = string.Empty;
239
-
240
- [JsonPropertyName("customer")]
241
- public string Customer { get; init; } = string.Empty;
242
-
243
- [JsonPropertyName("value")]
244
- public decimal Value { get; init; }
245
-
246
- [JsonPropertyName("status")]
247
- public string Status { get; init; } = string.Empty;
248
-
249
- [JsonPropertyName("billingType")]
250
- public string BillingType { get; init; } = string.Empty;
251
-
252
- [JsonPropertyName("dueDate")]
253
- public string DueDate { get; init; } = string.Empty;
254
-
255
- [JsonPropertyName("invoiceUrl")]
256
- public string? InvoiceUrl { get; init; }
257
-
258
- [JsonPropertyName("bankSlipUrl")]
259
- public string? BankSlipUrl { get; init; }
260
-
261
- [JsonPropertyName("externalReference")]
262
- public string? ExternalReference { get; init; }
263
- }
264
-
265
- public record AsaasPixQrCode
266
- {
267
- [JsonPropertyName("encodedImage")]
268
- public string? EncodedImage { get; init; }
269
-
270
- [JsonPropertyName("payload")]
271
- public string? Payload { get; init; }
272
-
273
- [JsonPropertyName("expirationDate")]
274
- public string? ExpirationDate { get; init; }
275
- }
276
-
277
- public record AsaasSubscription
278
- {
279
- [JsonPropertyName("id")]
280
- public string Id { get; init; } = string.Empty;
281
-
282
- [JsonPropertyName("customer")]
283
- public string Customer { get; init; } = string.Empty;
284
-
285
- [JsonPropertyName("value")]
286
- public decimal Value { get; init; }
287
-
288
- [JsonPropertyName("status")]
289
- public string Status { get; init; } = string.Empty;
290
-
291
- [JsonPropertyName("cycle")]
292
- public string Cycle { get; init; } = string.Empty;
293
-
294
- [JsonPropertyName("nextDueDate")]
295
- public string NextDueDate { get; init; } = string.Empty;
296
-
297
- [JsonPropertyName("externalReference")]
298
- public string? ExternalReference { get; init; }
299
- }
300
-
301
- public record AsaasListResponse<T>
302
- {
303
- [JsonPropertyName("data")]
304
- public List<T>? Data { get; init; }
305
-
306
- [JsonPropertyName("totalCount")]
307
- public int TotalCount { get; init; }
308
- }
309
-
310
- public class AsaasException : Exception
311
- {
312
- public AsaasException(string message) : base(message) { }
313
- public AsaasException(string message, Exception innerException) : base(message, innerException) { }
314
- }
315
-
316
- public static class AsaasServiceExtensions
317
- {
318
- public static IServiceCollection AddAsaasClient(this IServiceCollection services, IConfiguration configuration)
319
- {
320
- services.Configure<AsaasOptions>(configuration.GetSection(AsaasOptions.SectionName));
321
-
322
- services.AddHttpClient<IAsaasClient, AsaasClient>((sp, client) =>
323
- {
324
- var options = sp.GetRequiredService<IOptions<AsaasOptions>>().Value;
325
- client.BaseAddress = new Uri(options.BaseUrl.TrimEnd('/') + "/");
326
- client.DefaultRequestHeaders.Add("access_token", options.ApiKey);
327
- client.DefaultRequestHeaders.Add("User-Agent", "MORPH-SPEC/1.0");
328
- });
329
-
330
- return services;
331
- }
332
- }